test_swprintf.cpp 876 B

1234567891011121314151617181920212223242526
  1. #include <gtest/gtest.h>
  2. extern "C"{
  3. #include "common.h"
  4. #include "palcommon.h"
  5. #include "text.h"
  6. }
  7. #define swprintf_wrapper( buffer, count, format, ...) ( \
  8. PAL_swprintf( buffer, count, format, ##__VA_ARGS__ ), \
  9. buffer \
  10. )
  11. TEST(sdlpal, PAL_swprintf) {
  12. WCHAR test_buf[256];
  13. EXPECT_EQ(0, wcsncmp( L"测试", swprintf_wrapper( test_buf, sizeof(test_buf)/sizeof(WCHAR), L"%ls%ls", L"测", L"试"), wcslen(L"测试")));
  14. }
  15. TEST(sdlpal, PAL_swprintf2) {
  16. WCHAR test_buf[256];
  17. EXPECT_EQ(0, wcsncmp( L"测试 2", swprintf_wrapper( test_buf, sizeof(test_buf)/sizeof(WCHAR), L"%ls%ls %d", L"测", L"试", 2), wcslen(L"测试 2")));
  18. }
  19. TEST(sdlpal, PAL_swprintf3) {
  20. WCHAR test_buf[256];
  21. EXPECT_EQ(0, wcsncmp( L"测试 3", swprintf_wrapper( test_buf, sizeof(test_buf)/sizeof(WCHAR), L"%ls%ls %c", L"测", L"试", '3'), wcslen(L"测试 3")));
  22. }