Browse Source

Changed to use arrsize

Added extra test in ToUTF16
Anne Marije v/d Meer 11 years ago
parent
commit
098df8b41e
  1. 32
      Sources/Tests/CoreTests/test_plString.cpp

32
Sources/Tests/CoreTests/test_plString.cpp

@ -1,44 +1,44 @@
#include <plString.h> #include <plString.h>
#include <HeadSpin.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <wchar.h> #include <wchar.h>
TEST(PlStringTest,ToUtf16) TEST(PlStringTest,ToUtf16)
{ {
uint16_t text[] = {0x0061,0x0062,0x0063,0x0064}; uint16_t text[] = {0x0061,0x0062,0x0063,0x0064}; //abcd as in utf16
plStringBuffer<uint16_t> expected = plStringBuffer<uint16_t>(text,4); plStringBuffer<uint16_t> expected = plStringBuffer<uint16_t>(text,arrsize(text));
plStringBuffer<uint16_t> output = plString("abcd").ToUtf16(); plStringBuffer<uint16_t> output = plString("abcd").ToUtf16();
const uint16_t* c = output.GetData(); const uint16_t* c = output.GetData();
const uint16_t* d = expected.GetData(); const uint16_t* d = expected.GetData();
printf("expected size %d output size %d\n",expected.GetSize(),output.GetSize()); printf("expected size %d output size %d\n", expected.GetSize(), output.GetSize());
for(int i=0;i<expected.GetSize();i++) for (int i = 0; i<expected.GetSize(); i++)
{ {
printf("%u %s \n",c,c); printf("%u %s \n", c, c);
printf("%u %s \n",d,d); printf("%u %s \n", d, d);
EXPECT_EQ(d, c);
c++; c++;
d++; d++;
} }
} }
TEST(PlStringTest,ToWchar) TEST(PlStringTest,ToWchar)
{ {
wchar_t text[] =L"abcdé"; wchar_t text[] =L"abcd\u00E9";
plStringBuffer<wchar_t> expected = plStringBuffer<wchar_t>(text,sizeof(text)); plStringBuffer<wchar_t> expected = plStringBuffer<wchar_t>(text,arrsize(text));
plStringBuffer<wchar_t> output = plString("abcdé").ToWchar(); plStringBuffer<wchar_t> output = plString("abcd\xC3\xA9").ToWchar();
const wchar_t* outputStr = output.GetData(); EXPECT_STREQ(expected.GetData(),output.GetData());
const wchar_t* expectedStr = expected.GetData();
EXPECT_STREQ(expectedStr,outputStr);
} }
TEST(PlStringTest,ToIso8859_1) TEST(PlStringTest,ToIso8859_1)
{ {
char text[] ="abcde"; char text[] ="abcde";
plStringBuffer<char> expected = plStringBuffer<char>(text,sizeof(text)); plStringBuffer<char> expected = plStringBuffer<char>(text,arrsize(text));
plStringBuffer<char> output = plString("abcde").ToIso8859_1(); plStringBuffer<char> output = plString("abcde").ToIso8859_1();
const char* outputStr = output.GetData(); EXPECT_STREQ(expected.GetData(),output.GetData());
const char* expectedStr = expected.GetData();
EXPECT_STREQ(expectedStr,outputStr);
} }
TEST(PlStringTest,Format) TEST(PlStringTest,Format)

Loading…
Cancel
Save