Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mutest for leetcode #36

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a8a7782
mutest for leetcode
invalid-email-address Apr 22, 2022
b95fb5d
添加字符串测试
invalid-email-address Apr 23, 2022
14e8b9a
covertz
invalid-email-address Apr 23, 2022
1dcd771
modify comment
invalid-email-address Apr 23, 2022
798192f
Z 字形变换
invalid-email-address Apr 23, 2022
e80b34a
update runtests.sh
invalid-email-address Apr 23, 2022
4319e28
Z型变换
invalid-email-address Apr 23, 2022
fc30453
comment the refer
invalid-email-address Apr 23, 2022
4f8155f
Merge branch 'master' of https://github.com/hamwastp/liblcthw into le…
invalid-email-address Apr 23, 2022
4bc1b0f
valgrind 内存检测发现指针使用不当问题
invalid-email-address Apr 23, 2022
3e65f20
merge
invalid-email-address Apr 23, 2022
5b227bf
Update README.md
hamwastp Apr 23, 2022
210eaeb
Merge branch 'leetcodemutest' of https://github.com/hamwastp/liblcthw…
invalid-email-address Apr 23, 2022
2adf610
Leetcodemutest (#1)
hamwastp Apr 23, 2022
5881ee9
Update README.md
hamwastp Apr 23, 2022
6dc28d2
Update README.md
hamwastp Apr 23, 2022
02fd182
Update README.md
hamwastp Apr 23, 2022
c8fbce5
Update README.md
hamwastp Apr 23, 2022
0641cc1
消除gcc不必要的告警
invalid-email-address Apr 23, 2022
275d9d9
monitor file change
invalid-email-address Apr 23, 2022
1cbb744
Makefile
invalid-email-address Apr 23, 2022
c0f0e19
Leetcodemutest (#2)
hamwastp Apr 23, 2022
0fa780d
Update zigzagconversion.c
hamwastp Apr 23, 2022
b809bc6
Update minunit.h
hamwastp Apr 24, 2022
8b6af82
Merge branch 'master' of https://github.com/hamwastp/liblcthw into le…
invalid-email-address Apr 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
添加字符串测试
  • Loading branch information
root committed Apr 23, 2022
commit b95fb5db3e57a9ee8476c7a559429ce9e335aa5c
20 changes: 20 additions & 0 deletions tests/leetcode/mutest_tests.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "../minunit.h"
#include <assert.h>

// Just Do It for new suit
// the testcase corresponding C algo file

MU_TEST(example_test)
{
//char* actual = convert((char*)"PAYPALISHIRING", 3);
mu_assert_eq(111, 111);
mu_assert_not_eq(111, 110);
mu_assert_str_eq("PAYPALISHIRING", "PAYPALISHIRING");
mu_assert_str_not_eq("PAYPALISHIRING", "PAHNAPLSIIGYIR");
return NULL;
}

// Just Do It for new suit
//# make clean;make TESTAREA=leetcode TESTSUIT=mutest
//# make clean;make TESTAREA=leetcode TESTSUIT="\*"
RUN_TESTS_EX()
43 changes: 43 additions & 0 deletions tests/minunit.h
Original file line number Diff line number Diff line change
@@ -22,6 +22,49 @@
}
/* __END__ */

/* __ADD__ */
#define _mu_assert_fail_msg(actual, expected) \
fprintf(stderr, \
"\033[41;1m[FAIL]\033[0m"); \
log_err("actual:" #actual, \
"expected:" #expected);

#define _mu_assert_pass_msg() \
fprintf(stderr, \
"\033[32;1m[PASS]\n\033[0m");

#define mu_assert_eq(actual, expected) \
if (!(actual == expected)) { \
_mu_assert_fail_msg(actual, expected) \
} else { \
_mu_assert_pass_msg() \
}

#define mu_assert_not_eq(actual, expected) \
if (actual == expected) { \
_mu_assert_fail_msg(actual, expected) \
} else { \
_mu_assert_pass_msg() \
}

#define mu_assert_str_eq(actual, expected) \
if (strcmp((const char*)(actual), \
(const char*)(expected))) { \
_mu_assert_fail_msg(actual, expected) \
} else { \
_mu_assert_pass_msg() \
}

#define mu_assert_str_not_eq(actual, expected) \
if (!strcmp((const char*)(actual), \
(const char*)(expected))) { \
\
_mu_assert_fail_msg(actual, expected) \
} else { \
_mu_assert_pass_msg() \
}
/* __END__ */

#define mu_run_test(test) \
debug("\n-----%s", " " #test); \
message = test(); \