37 lines
983 B
C
37 lines
983 B
C
|
#include "../src/StringView/StringView.h"
|
||
|
#include <assert.h>
|
||
|
|
||
|
void test_split(void)
|
||
|
{
|
||
|
const char* source = "this,is,a,csv,header";
|
||
|
|
||
|
StringView sourceSV = StringView_FromString(source);
|
||
|
StringView delim = StringView_FromString(",");
|
||
|
StringView split;
|
||
|
|
||
|
assert(StringView_NextSplit(&split, &sourceSV, delim));
|
||
|
assert(StringView_Equal(split, StringView_FromString("this")));
|
||
|
|
||
|
assert(StringView_NextSplit(&split, &sourceSV, delim));
|
||
|
assert(StringView_Equal(split, StringView_FromString("is")));
|
||
|
|
||
|
assert(StringView_NextSplit(&split, &sourceSV, delim));
|
||
|
assert(StringView_Equal(split, StringView_FromString("a")));
|
||
|
|
||
|
assert(StringView_NextSplit(&split, &sourceSV, delim));
|
||
|
assert(StringView_Equal(split, StringView_FromString("csv")));
|
||
|
|
||
|
assert(StringView_NextSplit(&split, &sourceSV, delim));
|
||
|
assert(StringView_Equal(split, StringView_FromString("header")));
|
||
|
|
||
|
assert(! StringView_NextSplit(&split, &sourceSV, delim));
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
test_split();
|
||
|
return 0;
|
||
|
}
|