Changeset 9b20126 in mainline for uspace/lib/pcut/tests
- Timestamp:
- 2014-09-19T08:23:01Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c85a57f
- Parents:
- 15d0046
- Location:
- uspace/lib/pcut/tests
- Files:
-
- 8 added
- 3 edited
- 6 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/pcut/tests/abort.c
r15d0046 r9b20126 28 28 29 29 #include <pcut/pcut.h> 30 #include "tested.h"30 #include <stdlib.h> 31 31 32 32 PCUT_INIT 33 33 34 34 PCUT_TEST(access_null_pointer) { 35 int a = 5; 36 int *p = &a; 37 PCUT_ASSERT_INT_EQUALS(5, *p); 38 p = NULL; 39 PCUT_ASSERT_INT_EQUALS(5, *p); 35 abort(); 40 36 } 41 37 -
uspace/lib/pcut/tests/beforeafter.c
r15d0046 r9b20126 27 27 */ 28 28 29 #define _BSD_SOURCE 30 29 31 #include <pcut/pcut.h> 30 32 #include <stdlib.h> 31 33 #include <stdio.h> 34 35 /* 36 * Use sprintf_s in Windows but only with Microsoft compiler. 37 * Namely, let MinGW use snprintf. 38 */ 39 #if (defined(__WIN64) || defined(__WIN32) || defined(_WIN32)) && defined(_MSC_VER) 40 #define snprintf sprintf_s 41 #endif 32 42 33 43 PCUT_INIT … … 36 46 #define BUFFER_SIZE 512 37 47 38 PCUT_TEST_SUITE(suite_with_setup_and_teardown) 48 PCUT_TEST_SUITE(suite_with_setup_and_teardown); 39 49 40 50 PCUT_TEST_BEFORE { … … 48 58 } 49 59 50 PCUT_TEST( snprintf) {60 PCUT_TEST(test_with_setup_and_teardown) { 51 61 snprintf(buffer, BUFFER_SIZE - 1, "%d-%s", 56, "abcd"); 52 62 PCUT_ASSERT_STR_EQUALS("56-abcd", buffer); 53 63 } 54 64 55 PCUT_TEST_SUITE(another_without_setup) 65 PCUT_TEST_SUITE(another_without_setup); 56 66 57 PCUT_TEST( whatever) {67 PCUT_TEST(test_without_any_setup_or_teardown) { 58 68 PCUT_ASSERT_NULL(buffer); 59 69 } -
uspace/lib/pcut/tests/beforeafter.expected
r15d0046 r9b20126 1 1 1..2 2 2 #> Starting suite suite_with_setup_and_teardown. 3 ok 1 snprintf3 ok 1 test_with_setup_and_teardown 4 4 #> Finished suite suite_with_setup_and_teardown (failed 0 of 1). 5 5 #> Starting suite another_without_setup. 6 ok 2 whatever6 ok 2 test_without_any_setup_or_teardown 7 7 #> Finished suite another_without_setup (failed 0 of 1). -
uspace/lib/pcut/tests/errno.expected
r15d0046 r9b20126 2 2 #> Starting suite Default. 3 3 not ok 1 errno_value failed 4 # error: errno.c:46: Expected error 0 (EOK, Success) but got error 2 (No such file or directory)4 # error: errno.c:46: Expected error 0 (EOK, *****) but got error ***** (*****) 5 5 not ok 2 errno_variable failed 6 # error: errno.c:54: Expected error 0 (EOK, Success) but got error 2 (No such file or directory)6 # error: errno.c:54: Expected error 0 (EOK, *****) but got error ***** (*****) 7 7 #> Finished suite Default (failed 2 of 2). -
uspace/lib/pcut/tests/teardown.c
r15d0046 r9b20126 50 50 51 51 52 PCUT_TEST_SUITE(with_failing_teardown) 52 PCUT_TEST_SUITE(with_failing_teardown); 53 53 54 54 PCUT_TEST_AFTER { -
uspace/lib/pcut/tests/teardownaborts.c
r15d0046 r9b20126 29 29 #include <stdio.h> 30 30 #include <pcut/pcut.h> 31 #include "tested.h"31 #include <stdlib.h> 32 32 33 33 PCUT_INIT 34 34 35 35 PCUT_TEST_AFTER { 36 int a = 5; 37 int *p = &a; 38 PCUT_ASSERT_INT_EQUALS(5, *p); 39 p = NULL; 40 PCUT_ASSERT_INT_EQUALS(5, *p); 36 abort(); 41 37 } 42 38 -
uspace/lib/pcut/tests/teardownaborts.expected
r15d0046 r9b20126 2 2 #> Starting suite Default. 3 3 not ok 1 print_and_fail aborted 4 # error: nullteardown.c:45: Pointer <NULL> ought not to be NULL4 # error: teardownaborts.c:41: Pointer <NULL> ought not to be NULL 5 5 # stdio: Tear-down will cause null pointer access... 6 6 #> Finished suite Default (failed 1 of 1). -
uspace/lib/pcut/tests/timeout.c
r15d0046 r9b20126 28 28 29 29 #include <pcut/pcut.h> 30 31 #ifdef __unix 30 32 #include <unistd.h> 33 #endif 34 #if defined(__WIN64) || defined(__WIN32) || defined(_WIN32) 35 #include <windows.h> 36 #endif 37 31 38 #include <stdio.h> 32 39 #include "tested.h" 40 41 static void my_sleep(int sec) { 42 #ifdef __unix 43 sleep(sec); 44 #endif 45 #if defined(__WIN64) || defined(__WIN32) || defined(_WIN32) 46 Sleep(1000 * sec); 47 #endif 48 } 33 49 34 50 PCUT_INIT … … 36 52 PCUT_TEST(shall_time_out) { 37 53 printf("Text before sleeping.\n"); 38 sleep(PCUT_DEFAULT_TEST_TIMEOUT * 5);54 my_sleep(PCUT_DEFAULT_TEST_TIMEOUT * 5); 39 55 printf("Text after the sleep.\n"); 40 56 } … … 43 59 PCUT_TEST_SET_TIMEOUT(PCUT_DEFAULT_TEST_TIMEOUT * 3)) { 44 60 printf("Text before sleeping.\n"); 45 sleep(PCUT_DEFAULT_TEST_TIMEOUT * 2);61 my_sleep(PCUT_DEFAULT_TEST_TIMEOUT * 2); 46 62 printf("Text after the sleep.\n"); 47 63 }
Note:
See TracChangeset
for help on using the changeset viewer.