Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cstr_tests.cpp « tests « base « src - github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d0c810182dac204969880901d3cbacb5ed633371 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
 * \file   cstr_tests.cpp
 * \brief  C string automated tests.
 * \author Copyright (c) 2002-2008 Jason Perkins and the Premake project
 */

#include "premake.h"
#include "testing/testing.h"
extern "C" {
#include "base/cstr.h"
}

SUITE(cstr)
{
	/**************************************************************************
	 * cstr_ends_with() tests
	 **************************************************************************/

	TEST(CStrEndsWith_ReturnsTrue_OnMatch)
	{
		CHECK(cstr_ends_with("Abcdef", "def"));
	}

	TEST(CStrEndsWith_ReturnsFalse_OnMismatch)
	{
		CHECK(!cstr_ends_with("Abcdef", "ghi"));
	}

	TEST(CStrEndsWith_ReturnsFalse_OnLongerNeedle)
	{
		CHECK(!cstr_ends_with("Abc", "Abcdef"));
	}

	TEST(CStrEndsWith_ReturnsFalse_OnNullHaystack)
	{
		CHECK(!cstr_ends_with(NULL, "ghi"));
	}

	TEST(CStrEndsWith_ReturnsFalse_OnNullNeedle)
	{
		CHECK(!cstr_ends_with("Abc", NULL));
	}


	/**************************************************************************
	 * cstr_eq() tests
	 **************************************************************************/

	TEST(CStrEq_ReturnsTrue_OnMatch)
	{
		CHECK(cstr_eq("A string", "A string"));
	}

	TEST(CStrEq_ReturnsFalse_OnMismatch)
	{
		CHECK(!cstr_eq("A string", "A different string"));
	}

	TEST(CStrEq_ReturnsFalse_OnNullTarget)
	{
		CHECK(!cstr_eq(NULL, "something"));
	}

	TEST(CStrEq_ReturnsFalse_OnNullPattern)
	{
		CHECK(!cstr_eq("something", NULL));
	}
}