コード例 #1
0
ファイル: TestURIUtils.cpp プロジェクト: CaptainRewind/xbmc
TEST_F(TestURIUtils, UpdateUrlEncoding)
{
  std::string oldUrl = "stack://rar://%2fpath%2fto%2farchive%2fsome%2darchive%2dfile%2eCD1%2erar/video.avi , rar://%2fpath%2fto%2farchive%2fsome%2darchive%2dfile%2eCD2%2erar/video.avi";
  std::string newUrl = "stack://rar://%2fpath%2fto%2farchive%2fsome-archive-file.CD1.rar/video.avi , rar://%2fpath%2fto%2farchive%2fsome-archive-file.CD2.rar/video.avi";

  EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl));
  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());

  oldUrl = "rar://%2fpath%2fto%2farchive%2fsome%2darchive%2efile%2erar/video.avi";
  newUrl = "rar://%2fpath%2fto%2farchive%2fsome-archive.file.rar/video.avi";
  
  EXPECT_TRUE(URIUtils::UpdateUrlEncoding(oldUrl));
  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
  
  oldUrl = "/path/to/some/long%2dnamed%2efile";
  newUrl = "/path/to/some/long%2dnamed%2efile";
  
  EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
  
  oldUrl = "/path/to/some/long-named.file";
  newUrl = "/path/to/some/long-named.file";
  
  EXPECT_FALSE(URIUtils::UpdateUrlEncoding(oldUrl));
  EXPECT_STRCASEEQ(newUrl.c_str(), oldUrl.c_str());
}
コード例 #2
0
ファイル: stdio_test.cpp プロジェクト: CriGio/platform_bionic
TEST(stdio, snprintf_g_special) {
  char buf[BUFSIZ];
  snprintf(buf, sizeof(buf), "%g", nan(""));
  EXPECT_STRCASEEQ("NaN", buf);

  snprintf(buf, sizeof(buf), "%g", HUGE_VAL);
  EXPECT_STRCASEEQ("Inf", buf);
}
コード例 #3
0
ファイル: LayoutLocaleTest.cpp プロジェクト: mirror/chromium
TEST(LayoutLocaleTest, Get) {
  LayoutLocale::clearForTesting();

  EXPECT_EQ(nullptr, LayoutLocale::get(nullAtom));

  EXPECT_EQ(emptyAtom, LayoutLocale::get(emptyAtom)->localeString());

  EXPECT_STRCASEEQ("en-us",
                   LayoutLocale::get("en-us")->localeString().ascii().data());
  EXPECT_STRCASEEQ("ja-jp",
                   LayoutLocale::get("ja-jp")->localeString().ascii().data());

  LayoutLocale::clearForTesting();
}
コード例 #4
0
ファイル: TestURIUtils.cpp プロジェクト: CaptainRewind/xbmc
TEST_F(TestURIUtils, GetRealPath)
{
  std::string ref;
  
  ref = "/path/to/file/";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath(ref).c_str());
  
  ref = "path/to/file";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("../path/to/file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("./path/to/file").c_str());

  ref = "/path/to/file";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath(ref).c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("/path/to/./file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("/./path/to/./file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("/path/to/some/../file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("/../path/to/some/../file").c_str());

  ref = "/path/to";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("/path/to/some/../file/..").c_str());

#ifdef TARGET_WINDOWS
  ref = "\\\\path\\to\\file\\";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath(ref).c_str());
  
  ref = "path\\to\\file";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("..\\path\\to\\file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath(".\\path\\to\\file").c_str());

  ref = "\\\\path\\to\\file";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath(ref).c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("\\\\path\\to\\.\\file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("\\\\.\\path/to\\.\\file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("\\\\path\\to\\some\\..\\file").c_str());
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("\\\\..\\path\\to\\some\\..\\file").c_str());

  ref = "\\\\path\\to";
  EXPECT_STREQ(ref.c_str(), URIUtils::GetRealPath("\\\\path\\to\\some\\..\\file\\..").c_str());
#endif

  // test rar/zip paths
  ref = "rar://%2fpath%2fto%2frar/subpath/to/file";
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath(ref).c_str());
  
  // test rar/zip paths
  ref = "rar://%2fpath%2fto%2frar/subpath/to/file";
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("rar://%2fpath%2fto%2frar/../subpath/to/file").c_str());
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("rar://%2fpath%2fto%2frar/./subpath/to/file").c_str());
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("rar://%2fpath%2fto%2frar/subpath/to/./file").c_str());
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("rar://%2fpath%2fto%2frar/subpath/to/some/../file").c_str());
  
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("rar://%2fpath%2fto%2f.%2frar/subpath/to/file").c_str());
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("rar://%2fpath%2fto%2fsome%2f..%2frar/subpath/to/file").c_str());

  // test rar/zip path in rar/zip path
  ref ="zip://rar%3A%2F%2F%252Fpath%252Fto%252Frar%2Fpath%2Fto%2Fzip/subpath/to/file";
  EXPECT_STRCASEEQ(ref.c_str(), URIUtils::GetRealPath("zip://rar%3A%2F%2F%252Fpath%252Fto%252Fsome%252F..%252Frar%2Fpath%2Fto%2Fsome%2F..%2Fzip/subpath/to/some/../file").c_str());
}
コード例 #5
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIo32)
{
    const char* str[3] = { "00 00", "020000000000 05252525252", "037777777777 012525252525" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0%" PRIo32 " 0%" PRIo32, u32[i], u32[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #6
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIu32)
{
    const char* str[3] = { "0 0", "2147483648 715827882", "4294967295 1431655765" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIu32 " %" PRIu32, u32[i], u32[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #7
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIx16)
{
    const char* str[3] = { "0x0 0x0", "0x8000 0x2aaa", "0xffff 0x5555" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0x%" PRIx16 " 0x%" PRIx16, u16[i], u16[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #8
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIu16)
{
    const char* str[3] = { "0 0", "32768 10922", "65535 21845" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIu16 " %" PRIu16, u16[i], u16[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #9
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIu8)
{
    const char* str[3] = { "0 0", "128 42", "255 85" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIu8 " %" PRIu8, u8[i], u8[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #10
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIiMAX)
{
    const char* str[3] = { "-9223372036854775807 9223372036854775806", "0 -1", "9223372036854775807 -9223372036854775808" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIiMAX " %" PRIiMAX, s64[i], ~s64[i]);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #11
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIi32)
{
    const char* str[3] = { "-2147483648 2147483647", "0 -1", "2147483647 -2147483648" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIi32 " %" PRIi32, s32[i], ~s32[i]);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #12
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIi16)
{
    const char* str[3] = { "-32768 32767", "0 -1", "32767 -32768" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIi16 " %" PRIi16, s16[i], ~s16[i]);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #13
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIi8)
{
    const char* str[3] = { "-128 127", "0 -1", "127 -128" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIi8 " %" PRIi8, s8[i], ~s8[i]);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #14
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIX32)
{
    const char* str[3] = { "0x0 0x0", "0x80000000 0x2AAAAAAA", "0xFFFFFFFF 0x55555555" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0x%" PRIX32 " 0x%" PRIX32, u32[i], u32[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #15
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIu64)
{
    const char* str[3] = { "0 0", "922337203685477580 307445734561825860", "1844674407370955159 614891469123651719" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIu64 " %" PRIu64, u64[i], u64[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #16
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIXMAX)
{
    const char* str[3] = { "0x8000000000000001 0xD555555555555556", "0x0 0x0", "0x7FFFFFFFFFFFFFFF 0x2AAAAAAAAAAAAAAA" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0x%" PRIXMAX " 0x%" PRIXMAX, s64[i], s64[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #17
0
TEST_F(libp2p_error_test, test_libp2p_error_interfaces)
{
	int32_t m_error = 1002;
	int32_t m_act_error = INT32_MAX;
	const char* m_error_string = "file io error";

	libp2p_set_last_error(m_error);
	m_act_error = libp2p_get_last_error();
	EXPECT_EQ(m_error, m_act_error);
	EXPECT_STRCASEEQ(m_error_string, libp2p_get_error_info(m_act_error));

	m_error = 10005;
	m_error_string = "Unknown error";
	libp2p_set_last_error(m_error);
	m_act_error = libp2p_get_last_error();
	EXPECT_EQ(m_error, m_act_error);
	EXPECT_STRCASEEQ(m_error_string, libp2p_get_error_info(m_act_error));
}
コード例 #18
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIoMAX)
{
    const char* str[3] = { "01000000000000000000001 01525252525252525252526", "00 00", "0777777777777777777777 0252525252525252525252" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0%" PRIoMAX " 0%" PRIoMAX, s64[i], s64[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #19
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIuMAX)
{
    const char* str[3] = { "9223372036854775809 15372286728091293014", "0 0", "9223372036854775807 3074457345618258602" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIuMAX " %" PRIuMAX, s64[i], s64[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #20
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIX64)
{
    const char* str[3] = { "0x0 0x0", "0xccccccccccccccc 0x444444444444444", "0x1999999999999997 0x888888888888887" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0x%" PRIX64 " 0x%" PRIX64, u64[i], u64[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #21
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIo64)
{
    const char* str[3] = { "00 00", "063146314631463146314 021042104210421042104", "0146314631463146314627 042104210421042104207" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0%" PRIo64 " 0%" PRIo64, u64[i], u64[i]/3);
        EXPECT_STRCASEEQ(str[i], buf);
    }
}
コード例 #22
0
ファイル: first_test.cpp プロジェクト: idgetto/rah-milk
TEST_F(FirstTest, CString) {
    EXPECT_STREQ("Hello", "Hello");

    char potato[] = "Potato";
    char dogs[] = "Dogs";
    EXPECT_STRNE(potato, dogs);
    EXPECT_STRNE(nullptr, "");

    EXPECT_STRCASEEQ("CAT", "Cat");
    EXPECT_STRCASENE("mouse", "rat");
}
コード例 #23
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIiPTR)
{
    const char* str32bit[3] = { "1 -2147483648", "0 0", "-1 2147483647" };
    const char* str64bit[3] = { "-9223372036854775807 9223372036854775806", "0 -1", "9223372036854775807 -9223372036854775808" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIdPTR " %" PRIdPTR, s64[i], ~s64[i]);
        switch (sizeof(void*))
        {
            case 4:
                EXPECT_STRCASEEQ(str32bit[i], buf);
                break;
            case 8:
                EXPECT_STRCASEEQ(str64bit[i], buf);
                break;
            default:
                ASSERT_TRUE(sizeof(void*) == 4 || sizeof(void*) == 8);
                break;
        }
    }
}
コード例 #24
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIXPTR)
{
    const char* str32bit[3] = { "0x1 0x80000000", "0x0 0x0", "0xFFFFFFFF 0x7FFFFFFF" };
    const char* str64bit[3] = { "0x8000000000000001 0xD555555555555556", "0x0 0x0", "0x7FFFFFFFFFFFFFFF 0x2AAAAAAAAAAAAAAA" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0x%" PRIXPTR " 0x%" PRIXPTR, s64[i], s64[i]/3);
        switch (sizeof(void*))
        {
            case 4:
                EXPECT_STRCASEEQ(str32bit[i], buf);
                break;
            case 8:
                EXPECT_STRCASEEQ(str64bit[i], buf);
                break;
            default:
                ASSERT_TRUE(sizeof(void*) == 4 || sizeof(void*) == 8);
                break;
        }
    }
}
コード例 #25
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIoPTR)
{
    const char* str32bit[3] = { "01 020000000000", "00 00", "037777777777 017777777777" };
    const char* str64bit[3] = { "01000000000000000000001 01525252525252525252526", "00 00", "0777777777777777777777 0252525252525252525252" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "0%" PRIoPTR " 0%" PRIoPTR, s64[i], s64[i]/3);
        switch (sizeof(void*))
        {
            case 4:
                EXPECT_STRCASEEQ(str32bit[i], buf);
                break;
            case 8:
                EXPECT_STRCASEEQ(str64bit[i], buf);
                break;
            default:
                ASSERT_TRUE(sizeof(void*) == 4 || sizeof(void*) == 8);
                break;
        }
    }
}
コード例 #26
0
TEST_F(SafeStringInterfaceTest, sprintfWithPRIuPTR)
{
    const char* str32bit[3] = { "1 2147483648", "0 0", "4294967295 2147483647" };
    const char* str64bit[3] = { "9223372036854775809 15372286728091293014", "0 0", "9223372036854775807 3074457345618258602" };
    for (int i = 0; i < 3; i++)
    {
        xme_hal_safeString_snprintf(buf, BUFFER_SIZE, "%" PRIuPTR " %" PRIuPTR, s64[i], s64[i]/3);
        switch (sizeof(void*))
        {
            case 4:
                EXPECT_STRCASEEQ(str32bit[i], buf);
                break;
            case 8:
                EXPECT_STRCASEEQ(str64bit[i], buf);
                break;
            default:
                ASSERT_TRUE(sizeof(void*) == 4 || sizeof(void*) == 8);
                break;
        }
    }
}
コード例 #27
0
ファイル: test1.cpp プロジェクト: whuthj/siren
/**
 * bool 检查
 | Fatal assertion | Nonfatal assertion | Verifies |
 |-----------------+--------------------+----------|
 | ASSERT_TRUE     | EXPECT_TRUE        | true     |
 | ASSERT_FALSE    | EXPECT_FALSE       | false    |
 |-----------------+--------------------+----------|
 
 数值型 检查
 | Fatal assertion             | Nonfatal assertion          | Verifies           |
 |-----------------------------+-----------------------------+--------------------|
 | ASSERT_EQ(expected, actual) | EXPECT_EQ(expected, actual) | expected == actual |
 | ASSERT_NE(v1, v2)           | EXPECT_NE(v1, v2)           | v1 != v2           |
 | ASSERT_LT(v1, v2)           | EXPECT_LT(v1, v2)           | v1 < v2            |
 | ASSERT_LE(v1, v2)           | EXPECT_LE(v1, v2)           | v1 <= v2           |
 | ASSERT_GT(v1, v2)           | EXPECT_GT(v1, v2)           | v1 > v2            |
 | ASSERT_GE(v1, v2)           | EXPECT_GE(v1, v2)           | v1 >= v2           |
 |-----------------------------+-----------------------------+--------------------|

 字符串 检查
 | Fatal assertion          | Nonfatal assertion       | Verifies              |
 |--------------------------+--------------------------+-----------------------|
 | ASSERT_STREQ(s1, s2)     | EXPECT_STREQ(v1, v2)     | v1 == v2              |
 | ASSERT_STRNE(s1, s2)     | EXPECT_STREQ(v1, v2)     | v1 != v2              |
 | ASSERT_STRCASEEQ(s1, s2) | EXPECT_STRCASEEQ(v1, v2) | v1 == v2, ignore case |
 | ASSERT_STRCASENE(s1, s2) | EXPECT_STRCASENE(v1, v2) | v1 != v2, ignore case |
 |--------------------------+--------------------------+-----------------------|
 *STREQ*和*STRNE*同时支持char*和wchar_t*类型的,*STRCASEEQ*和*STRCASENE*却只接收char*.

 **/
TEST(Lesson2, Section2)
{
    char* pszCoderZh = "CoderZh";
    wchar_t* wszCoderZh = L"CoderZh";
    std::string strCoderZh = "CoderZh";
    std::wstring wstrCoderZh = L"CoderZh";

    EXPECT_STREQ("CoderZh", pszCoderZh);
    EXPECT_STREQ(L"CoderZh", wszCoderZh);
    EXPECT_STRNE("CnBlogs", pszCoderZh);
    EXPECT_STRNE(L"CnBlogs", wszCoderZh);
    EXPECT_STRCASEEQ("coderzh", pszCoderZh);
    //EXPECT_STRCASEEQ(L"coderzh", wszCoderZh);    不支持
    EXPECT_STREQ("CoderZh", strCoderZh.c_str());
    EXPECT_STREQ(L"CoderZh", wstrCoderZh.c_str());
}
コード例 #28
0
ファイル: containerTests.cpp プロジェクト: justindujardin/ACL
TEST(ListTest,Insertion) {
   // List
   ACLib::List<const char *> nameList;
   static const char *names[] = { "bill", "patricia", "rodney", "colbert", "robert", NULL };
   U32 i = 0;
   const char *nameIter = names[i];
   while(nameIter != NULL)
   {
      nameList.pushBack(nameIter);
      nameIter = names[++i];
   }
   for(i = 0; i < nameList.getSize(); i++)
   {
      EXPECT_STRCASEEQ(nameList[i],names[i]);
   }
}
コード例 #29
0
VOID TEST(SampleTest, FastSampleMacrosTest) 
{
    EXPECT_TRUE(1);
    EXPECT_FALSE(0);
    
    EXPECT_EQ(1, 1); // ==
    EXPECT_NE(1, 2); // !=
    EXPECT_LE(1, 2); // <=
    EXPECT_LT(1, 2); // <
    EXPECT_GE(2, 1); // >=
    EXPECT_GT(2, 1); // >

    EXPECT_STREQ("winlin", "winlin");
    EXPECT_STRNE("winlin", "srs");
    EXPECT_STRCASEEQ("winlin", "Winlin");
    EXPECT_STRCASENE("winlin", "srs");
    
    EXPECT_FLOAT_EQ(1.0, 1.000000000000001);
    EXPECT_DOUBLE_EQ(1.0, 1.0000000000000001);
    EXPECT_NEAR(10, 15, 5);
}
コード例 #30
0
ファイル: HmacTest.cpp プロジェクト: dettonijr/libcryptosec
/**
 * Gera e testa Hmac com o algoritmo sha1 de um arquivo binario e chave de 63 bytes
 */
TEST_F(HmacTest, HmacSha1FromBinaryFile_key63bytes) {
	fstream file ("files/binaryFile", ios::in|ios::binary|ios::ate);
	if(file.is_open()){
		file.seekg (0, file.end);
		int length = file.tellg();
		file.seekg (0, file.beg);

		unsigned char * memblock = new unsigned char [length];

		file.read ((char*)memblock, length);
		file.close();

		hmac.init(HmacTest::key63bytes, MessageDigest::SHA1);
		ByteArray b(memblock, length);
		delete[] memblock;
		EXPECT_STRCASEEQ("2dce9d5c64b7879fb52656953ae128a1eb2cd148",
				hmac.doFinal(b).toHex().c_str());

	}else{
		FAIL();
	}
}