Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2755 from soheibthriber/buildbot-embedded-unittests
Buildbot embedded unittests
- Loading branch information
Showing
14 changed files
with
369 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <gpac/setup.h> | ||
|
||
#define unittest(suffix) void test_##suffix(void) | ||
|
||
extern int checks_passed; | ||
extern int checks_failed; | ||
|
||
static Bool verbose_ut = GF_FALSE; | ||
static Bool fatal_ut = GF_TRUE; | ||
|
||
#define assert_true(expr) \ | ||
do { \ | ||
if (expr) { \ | ||
if (verbose_ut) printf("Assertion passed: \"%s\", File: \"%s\", Line: %d, Function: \"%s\"\n", #expr, __FILE__, __LINE__, __ASSERT_FUNCTION); \ | ||
checks_passed++; \ | ||
} else { \ | ||
checks_failed++; \ | ||
if (fatal_ut) checks_failed|=0x8000000; \ | ||
} \ | ||
} while (0) | ||
|
||
#define assert_false(expr) assert_true(!(expr)) | ||
#define assert_equal_str(str1, str2) assert_true(!strcmp((str1), (str2))) | ||
#define assert_not_equal_str(str1, str2) assert_true(strcmp((str1), (str2))) | ||
#define assert_equal(a, b) assert_true((a) == (b)) | ||
#define assert_greater(a, b) assert_true((a) > (b)) | ||
#define assert_greater_equal(a, b) assert_true((a) >= (b)) | ||
#define assert_less(a, b) assert_true((a) < (b)) | ||
#define assert_less_equal(a, b) assert_true((a) <= (b)) | ||
#define assert_not_null(ptr) assert_true((ptr) != NULL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <gpac/main.h> | ||
#include "tests.h" | ||
|
||
unittest(gf_sys_word_match) | ||
{ | ||
// Test exact match scenario | ||
assert_true(gf_sys_word_match("abc", "abc")); | ||
|
||
// Test short orig, longer dst scenario | ||
assert_true(gf_sys_word_match("abc", "abcd")); | ||
|
||
// Test short dst, longer orig scenario | ||
assert_true(gf_sys_word_match("abcd", "abc")); | ||
|
||
// Test scenario with ':' in orig but not in dst | ||
assert_false(gf_sys_word_match("a:b:c", "xyz")); | ||
|
||
// Test scenario with ':' in dst but not in orig | ||
assert_false(gf_sys_word_match("abc", "x:y:z")); | ||
|
||
// Test strnistr match scenario | ||
assert_true(gf_sys_word_match("abc", "xabcz")); | ||
|
||
// Test repeated characters scenario | ||
assert_false(gf_sys_word_match("aabbc", "axayabaz")); | ||
|
||
// Test match*2 < olen scenario | ||
assert_false(gf_sys_word_match("abc", "xyz")); | ||
|
||
// Test half characters in order scenario | ||
assert_true(gf_sys_word_match("abcd", "aebfcd")); | ||
|
||
// Test null pointer | ||
assert_true(gf_sys_word_match(NULL, NULL)); | ||
assert_false(gf_sys_word_match("abc", NULL)); | ||
assert_false(gf_sys_word_match(NULL, "abc")); | ||
|
||
// Test empty string | ||
assert_true(gf_sys_word_match("", "")); | ||
assert_false(gf_sys_word_match("abc", "")); | ||
assert_false(gf_sys_word_match("", "abc")); | ||
|
||
// Test a very long string | ||
const char *longString = "a very long string that exceeds the normal limit of the function, it may go further and further until it can break the behaviour of the function apparently not easy so lets write more and more"; | ||
assert_true(gf_sys_word_match(longString, longString)); | ||
assert_false(gf_sys_word_match("abc", longString)); | ||
assert_false(gf_sys_word_match(longString, "abc")); | ||
|
||
// Test a non-ASCII buffer | ||
const char *nonAsciiBuffer = "\x01\x02\x03\xFF\xFE\xFD"; | ||
assert_false(gf_sys_word_match("abc", nonAsciiBuffer)); | ||
assert_false(gf_sys_word_match(nonAsciiBuffer, "abc")); | ||
assert_true(gf_sys_word_match(nonAsciiBuffer, nonAsciiBuffer)); | ||
|
||
// Test non-string: will crash because this exported function doesn't provide a str max len argument | ||
char str[3] = {'a', 'b', 'c'}; | ||
//DISABLED: gf_sys_word_match("abc", str); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "tests.h" | ||
|
||
char *xml_translate_xml_string(char *str); | ||
unittest(xml_translate_xml_string) | ||
{ | ||
assert_equal_str(xml_translate_xml_string("&"), "&"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.