/nobber/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/nobber/trunk
4 by Stream
* Moved functions to utils.h
1
#include <stddef.h>
2
#include <stdio.h>
3
#include <string.h>
4
#include "test_macros.h"
5
#define NOBBER_UTILS_IMPLEMENTAITON
6
#include "utils.h"
7
#define NOB_IMPLEMENTATION
8
#define NOB_STRIP_PREFIX
9
#include "nob.h"
10
11
int test_split_string () {
12
    setup_unit ();
13
    {
14
        char months[] = "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC\0";
15
        char *  months_arr[] = {"JAN\0","FEB\0","MAR\0","APR\0","MAY\0","JUN\0","JUL\0","AUG\0","SEP\0","OCT\0","NOV\0","DEC\0"};
16
        size_t tokens_len;
17
        char ** tokens = split_string (months, ',', &tokens_len);
18
        test_case (tokens_len == 12, "Expeted 12, got %zi", tokens_len);
19
        for (size_t i = 0; i < tokens_len; i++) {
20
            test_case (strcmp (tokens[i],months_arr[i]) == 0, "Expected %s, got %s", tokens[i], months_arr[i]);
21
        }
22
    }
23
    end_unit ();
24
}
25
26
int main ([[maybe_unused]] int argc,[[maybe_unused]] char * argv[]) {
27
    setup_suite ("Nobber");
28
    test_unit (test_split_string, "split_string");
29
    end_suite ();
30
}