File: strlen_test.c

package info (click to toggle)
libdbi-drivers 0.9.0-13
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,160 kB
  • sloc: ansic: 19,030; sh: 10,963; xml: 2,759; makefile: 584
file content (23 lines) | stat: -rw-r--r-- 653 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <cgreen/cgreen.h>
#include <string.h>

static void strlen_of_hello_should_be_five() {
    int length = strlen("Hello\0");
    assert_equal(length, 5, "Should be 5, but was %d", length);
}

static void strlen_of_empty_string_should_be_zero() {
    int length = strlen("\0");
    assert_equal(length, 0, "Should be 0, but was %d", length);
}

TestSuite *our_tests() {
    TestSuite *suite = create_test_suite();
    add_test(suite, strlen_of_hello_should_be_five);
    add_test(suite, strlen_of_empty_string_should_be_zero);
    return suite;
}

int main(int argc, char **argv) {
    return run_test_suite(our_tests(), create_text_reporter());
}