blob: 3d98e38b2e8c61b6a58a3c2eed8a5bfe7838088f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*
* Copyright 2010-2016 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
#include "test.h"
#include <bx/string.h>
#include <bx/crtimpl.h>
#include <bx/handlealloc.h>
bx::AllocatorI* g_allocator;
TEST_CASE("strnlen", "")
{
const char* test = "test";
REQUIRE(0 == bx::strnlen(test, 0) );
REQUIRE(2 == bx::strnlen(test, 2) );
REQUIRE(4 == bx::strnlen(test, UINT32_MAX) );
}
TEST_CASE("StringView", "")
{
bx::StringView sv("test");
REQUIRE(4 == sv.getLength() );
bx::CrtAllocator crt;
g_allocator = &crt;
typedef bx::StringT<&g_allocator> String;
String st(sv);
REQUIRE(4 == st.getLength() );
st.clear();
REQUIRE(0 == st.getLength() );
REQUIRE(4 == sv.getLength() );
sv.clear();
REQUIRE(0 == sv.getLength() );
}
|