xaizek / stic (License: MIT) (since 2018-12-07)
Simple Tests In C with optional automatic test registration in C.
Commit f38316820001750fcd75e7df50c99b8e69e24716

Add assert_wstring_ends_with() to stic
Author: xaizek
Author date (UTC): 2024-08-20 16:03
Committer name: xaizek
Committer date (UTC): 2024-08-20 16:13
Parent(s): 36574ec0c6146eb94333c6f7330254d36cabb538
Signing key: 99DC5E4DB05F6BE2
Tree: 3db756527f0566f5ee39532fff783eef9fb0571d
File Lines added Lines deleted
src/stic.c 11 0
src/stic.h 2 0
File src/stic.c changed (mode: 100644) (index 0342ad9..7c6a900)
... ... void stic_assert_string_ends_with(const char* expected, const char* actual, cons
415 415 stic_simple_test_result(strcmp(expected, actual+(strlen(actual)-strlen(expected)))==0, s, function, file, line); stic_simple_test_result(strcmp(expected, actual+(strlen(actual)-strlen(expected)))==0, s, function, file, line);
416 416 } }
417 417
418 void stic_assert_wstring_ends_with(const wchar_t expected[], const wchar_t actual[], const char function[], const char file[], unsigned int line)
419 {
420 char s[STIC_PRINT_BUFFER_SIZE];
421 #ifdef STIC_C99
422 snprintf(s, sizeof(s), "Expected \"%ls\" to end with \"%ls\"", actual, expected);
423 #else
424 snprintf(s, sizeof(s), "Wide string doesn't end with the expected suffix");
425 #endif
426 stic_simple_test_result(wcscmp(expected, actual+(wcslen(actual)-wcslen(expected)))==0, s, function, file, line);
427 }
428
418 429 void stic_assert_string_starts_with(const char* expected, const char* actual, const char* function, const char file[], unsigned int line) void stic_assert_string_starts_with(const char* expected, const char* actual, const char* function, const char file[], unsigned int line)
419 430 { {
420 431 char s[STIC_PRINT_BUFFER_SIZE]; char s[STIC_PRINT_BUFFER_SIZE];
File src/stic.h changed (mode: 100644) (index 087ec43..12ba03c)
... ... void stic_assert_double_equal(double expected, double actual, double delta, cons
41 41 void stic_assert_string_equal(const char* expected, const char* actual, const char* function, const char file[], unsigned int line); void stic_assert_string_equal(const char* expected, const char* actual, const char* function, const char file[], unsigned int line);
42 42 void stic_assert_wstring_equal(const wchar_t expected[], const wchar_t actual[], const char function[], const char file[], unsigned int line); void stic_assert_wstring_equal(const wchar_t expected[], const wchar_t actual[], const char function[], const char file[], unsigned int line);
43 43 void stic_assert_string_ends_with(const char* expected, const char* actual, const char* function, const char file[], unsigned int line); void stic_assert_string_ends_with(const char* expected, const char* actual, const char* function, const char file[], unsigned int line);
44 void stic_assert_wstring_ends_with(const wchar_t expected[], const wchar_t actual[], const char function[], const char file[], unsigned int line);
44 45 void stic_assert_string_starts_with(const char* expected, const char* actual, const char* function, const char file[], unsigned int line); void stic_assert_string_starts_with(const char* expected, const char* actual, const char* function, const char file[], unsigned int line);
45 46 void stic_assert_string_contains(const char* expected, const char* actual, const char* function, const char file[], unsigned int line); void stic_assert_string_contains(const char* expected, const char* actual, const char* function, const char file[], unsigned int line);
46 47 void stic_assert_string_doesnt_contain(const char* expected, const char* actual, const char* function, const char file[], unsigned int line); void stic_assert_string_doesnt_contain(const char* expected, const char* actual, const char* function, const char file[], unsigned int line);
 
... ... void stic_printf(char buf[], const char format[], ...);
67 68 #define assert_ulong_equal(expected, actual) do { stic_assert_ulong_equal(expected, actual, __FUNCTION__, __FILE__, __LINE__); } while (0) #define assert_ulong_equal(expected, actual) do { stic_assert_ulong_equal(expected, actual, __FUNCTION__, __FILE__, __LINE__); } while (0)
68 69 #define assert_string_equal(expected, actual) do { stic_assert_string_equal(expected, actual, __FUNCTION__, __FILE__, __LINE__); } while (0) #define assert_string_equal(expected, actual) do { stic_assert_string_equal(expected, actual, __FUNCTION__, __FILE__, __LINE__); } while (0)
69 70 #define assert_wstring_equal(expected, actual) do { stic_assert_wstring_equal(expected, actual, __FUNCTION__, __FILE__, __LINE__); } while (0) #define assert_wstring_equal(expected, actual) do { stic_assert_wstring_equal(expected, actual, __FUNCTION__, __FILE__, __LINE__); } while (0)
71 #define assert_wstring_ends_with(expected, actual) do { stic_assert_wstring_ends_with(expected, actual, __FUNCTION__, __FILE__, __LINE__); } while (0)
70 72 #define assert_n_array_equal(expected, actual, n) do { int stic_count; for(stic_count=0; stic_count<n; stic_count++) { char s_seatest[STIC_PRINT_BUFFER_SIZE]; stic_printf(s_seatest,"Expected %d to be %d at position %d", actual[stic_count], expected[stic_count], stic_count); stic_simple_test_result((expected[stic_count] == actual[stic_count]), s_seatest, __FUNCTION__, __FILE__, __LINE__);} } while (0) #define assert_n_array_equal(expected, actual, n) do { int stic_count; for(stic_count=0; stic_count<n; stic_count++) { char s_seatest[STIC_PRINT_BUFFER_SIZE]; stic_printf(s_seatest,"Expected %d to be %d at position %d", actual[stic_count], expected[stic_count], stic_count); stic_simple_test_result((expected[stic_count] == actual[stic_count]), s_seatest, __FUNCTION__, __FILE__, __LINE__);} } while (0)
71 73 #define assert_bit_set(bit_number, value) { stic_simple_test_result(((1 << bit_number) & value), " Expected bit to be set" , __FUNCTION__, __FILE__, __LINE__); } while (0) #define assert_bit_set(bit_number, value) { stic_simple_test_result(((1 << bit_number) & value), " Expected bit to be set" , __FUNCTION__, __FILE__, __LINE__); } while (0)
72 74 #define assert_bit_not_set(bit_number, value) { stic_simple_test_result(!((1 << bit_number) & value), " Expected bit not to to be set" , __FUNCTION__, __FILE__, __LINE__); } while (0) #define assert_bit_not_set(bit_number, value) { stic_simple_test_result(!((1 << bit_number) & value), " Expected bit not to to be set" , __FUNCTION__, __FILE__, __LINE__); } while (0)
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/stic

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/stic

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master