Skip to content

Commit

Permalink
Add regression test for str[n]casecmp
Browse files Browse the repository at this point in the history
  • Loading branch information
calc84maniac committed Feb 27, 2024
1 parent 30cfdf2 commit f979fd6
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/regression/bug0005/autotest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"transfer_files": [
"bin/DEMO.8xp"
],
"target": {
"name": "DEMO",
"isASM": true
},
"sequence": [
"action|launch",
"delay|200",
"hashWait|1",
"key|enter",
"delay|300",
"hashWait|2"
],
"hashes": {
"1": {
"description": "Output should be 0 1 0 1 -1 -1|0 0 1 0 -1 -1 0 1",
"start": "vram_start",
"size": "vram_16_size",
"expected_CRCs": [
"BC4B41AB"
]
},
"2": {
"description": "Exit",
"start": "vram_start",
"size": "vram_16_size",
"expected_CRCs": [
"FFAF89BA",
"101734A5",
"9DA19F44",
"A32840C8",
"349F4775"
]
}
}
}
18 changes: 18 additions & 0 deletions test/regression/bug0005/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ----------------------------
# Makefile Options
# ----------------------------

NAME = DEMO
ICON = icon.png
DESCRIPTION = "CE C Toolchain Demo"
COMPRESSED = NO
ARCHIVED = NO

CFLAGS = -Wall -Wextra -Oz
CXXFLAGS = -Wall -Wextra -Oz

PREFER_OS_LIBC = NO

# ----------------------------

include $(shell cedev-config --makefile)
45 changes: 45 additions & 0 deletions test/regression/bug0005/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <ti/screen.h>
#include <ti/getcsc.h>
#include <string.h>
#include <stdio.h>

void test(const char *a, const char *b)
{
int cmp = strcasecmp(a, b);
cmp = cmp < 0 ? -1 : (cmp > 0);
printf("%d ", cmp);
}

void testn(const char *a, const char *b, size_t n)
{
int cmp = strncasecmp(a, b, n);
cmp = cmp < 0 ? -1 : (cmp > 0);
printf("%d ", cmp);
}

int main(void)
{
os_ClrHome();

test("", "");
test("a", "");
test("abc", "ABC");
test("bad", "Apple");
test("bRiCk", "Bring");
test("bad", "Badger");
printf("\n");

testn("abc", "ABC", 3);
testn("bad", "Apple", 0);
testn("bad", "Apple", 6);
testn("bRiCk", "Bring", 3);
testn("bRiCk", "Bring", 4);
testn("bad", "Badger", 6);
testn("Hello", "HELLO WORLD!", 5);
testn("Hello", "HELLO WORLD!", 12);
printf("\n");

while (!os_GetCSC());

return 0;
}

0 comments on commit f979fd6

Please sign in to comment.