Example #1
0
TEST(stdio, snprintf_smoke) {
  char buf[BUFSIZ];

  snprintf(buf, sizeof(buf), "a");
  EXPECT_STREQ("a", buf);

  snprintf(buf, sizeof(buf), "%%");
  EXPECT_STREQ("%", buf);

  snprintf(buf, sizeof(buf), "01234");
  EXPECT_STREQ("01234", buf);

  snprintf(buf, sizeof(buf), "a%sb", "01234");
  EXPECT_STREQ("a01234b", buf);

  char* s = NULL;
  snprintf(buf, sizeof(buf), "a%sb", s);
  EXPECT_STREQ("a(null)b", buf);

  snprintf(buf, sizeof(buf), "aa%scc", "bb");
  EXPECT_STREQ("aabbcc", buf);

  snprintf(buf, sizeof(buf), "a%cc", 'b');
  EXPECT_STREQ("abc", buf);

  snprintf(buf, sizeof(buf), "a%db", 1234);
  EXPECT_STREQ("a1234b", buf);

  snprintf(buf, sizeof(buf), "a%db", -8123);
  EXPECT_STREQ("a-8123b", buf);

  snprintf(buf, sizeof(buf), "a%hdb", static_cast<short>(0x7fff0010));
  EXPECT_STREQ("a16b", buf);

  snprintf(buf, sizeof(buf), "a%hhdb", static_cast<char>(0x7fffff10));
  EXPECT_STREQ("a16b", buf);

  snprintf(buf, sizeof(buf), "a%lldb", 0x1000000000LL);
  EXPECT_STREQ("a68719476736b", buf);

  snprintf(buf, sizeof(buf), "a%ldb", 70000L);
  EXPECT_STREQ("a70000b", buf);

  snprintf(buf, sizeof(buf), "a%pb", reinterpret_cast<void*>(0xb0001234));
  EXPECT_STREQ("a0xb0001234b", buf);

  snprintf(buf, sizeof(buf), "a%xz", 0x12ab);
  EXPECT_STREQ("a12abz", buf);

  snprintf(buf, sizeof(buf), "a%Xz", 0x12ab);
  EXPECT_STREQ("a12ABz", buf);

  snprintf(buf, sizeof(buf), "a%08xz", 0x123456);
  EXPECT_STREQ("a00123456z", buf);

  snprintf(buf, sizeof(buf), "a%5dz", 1234);
  EXPECT_STREQ("a 1234z", buf);

  snprintf(buf, sizeof(buf), "a%05dz", 1234);
  EXPECT_STREQ("a01234z", buf);

  snprintf(buf, sizeof(buf), "a%8dz", 1234);
  EXPECT_STREQ("a    1234z", buf);

  snprintf(buf, sizeof(buf), "a%-8dz", 1234);
  EXPECT_STREQ("a1234    z", buf);

  snprintf(buf, sizeof(buf), "A%-11sZ", "abcdef");
  EXPECT_STREQ("Aabcdef     Z", buf);

  snprintf(buf, sizeof(buf), "A%s:%dZ", "hello", 1234);
  EXPECT_STREQ("Ahello:1234Z", buf);

  snprintf(buf, sizeof(buf), "a%03d:%d:%02dz", 5, 5, 5);
  EXPECT_STREQ("a005:5:05z", buf);

  void* p = NULL;
  snprintf(buf, sizeof(buf), "a%d,%pz", 5, p);
#if defined(__BIONIC__)
  EXPECT_STREQ("a5,0x0z", buf);
#else // __BIONIC__
  EXPECT_STREQ("a5,(nil)z", buf);
#endif // __BIONIC__

  snprintf(buf, sizeof(buf), "a%lld,%d,%d,%dz", 0x1000000000LL, 6, 7, 8);
  EXPECT_STREQ("a68719476736,6,7,8z", buf);

  snprintf(buf, sizeof(buf), "a_%f_b", 1.23f);
  EXPECT_STREQ("a_1.230000_b", buf);

  snprintf(buf, sizeof(buf), "a_%g_b", 3.14);
  EXPECT_STREQ("a_3.14_b", buf);

  snprintf(buf, sizeof(buf), "%1$s %1$s", "print_me_twice");
  EXPECT_STREQ("print_me_twice print_me_twice", buf);
}
static void GetGitRevRefMap()
{
	g_Git.SetConfigValue(L"branch.master.description", L"test");
	g_Git.SetConfigValue(L"branch.subdir/branch.description", L"multi\nline");

	MAP_REF_GITREVREFBROWSER refMap;
	CString err;
	EXPECT_EQ(0, GitRevRefBrowser::GetGitRevRefMap(refMap, 0, err));
	EXPECT_STREQ(L"", err);
	EXPECT_EQ(12U, refMap.size());

	GitRevRefBrowser rev = refMap[L"refs/heads/master"];
	EXPECT_STREQ(L"7c3cbfe13a929d2291a574dca45e4fd2d2ac1aa6", rev.m_CommitHash.ToString());
	EXPECT_STREQ(L"Sven Strickroth", rev.GetAuthorName());
	EXPECT_STREQ(L"2015-03-07 18:03:58", rev.GetAuthorDate().FormatGmt(L"%Y-%m-%d %H:%M:%S"));
	EXPECT_STREQ(L"Changed ASCII file", rev.GetSubject());
	EXPECT_STREQ(L"refs/remotes/origin/master", rev.m_UpstreamRef);
	EXPECT_STREQ(L"test", rev.m_Description);

	rev = refMap[L"refs/heads/signed-commit"];
	EXPECT_STREQ(L"4c5c93d2a0b368bc4570d5ec02ab03b9c4334d44", rev.m_CommitHash.ToString());
	EXPECT_STREQ(L"Sven Strickroth", rev.GetAuthorName());
	EXPECT_STREQ(L"2015-03-16 12:52:29", rev.GetAuthorDate().FormatGmt(L"%Y-%m-%d %H:%M:%S"));
	EXPECT_STREQ(L"Several actions", rev.GetSubject());
	EXPECT_STREQ(L"", rev.m_UpstreamRef);
	EXPECT_STREQ(L"", rev.m_Description);

	rev = refMap[L"refs/tags/also-signed"];
	EXPECT_STREQ(L"e89cb722e0f9b2eb763bb059dc099ee6c502a6d8", rev.m_CommitHash.ToString());
	EXPECT_STREQ(L"Sven Strickroth", rev.GetAuthorName());
	EXPECT_STREQ(L"2015-03-04 17:45:40", rev.GetAuthorDate().FormatGmt(L"%Y-%m-%d %H:%M:%S"));
	EXPECT_STREQ(L"Also signed", rev.GetSubject());
	EXPECT_STREQ(L"", rev.m_UpstreamRef);
	EXPECT_STREQ(L"", rev.m_Description);

	rev = refMap[L"refs/heads/subdir/branch"];
	EXPECT_STREQ(L"31ff87c86e9f6d3853e438cb151043f30f09029a", rev.m_CommitHash.ToString());
	EXPECT_STREQ(L"Sven Strickroth", rev.GetAuthorName());
	EXPECT_STREQ(L"2015-03-16 12:52:29", rev.GetAuthorDate().FormatGmt(L"%Y-%m-%d %H:%M:%S")); // used here, because author and commit time differ
	EXPECT_STREQ(L"Several actions", rev.GetSubject());
	EXPECT_STREQ(L"", rev.m_UpstreamRef);
	EXPECT_STREQ(L"multi\nline", rev.m_Description);

	refMap.clear();
	EXPECT_EQ(0, GitRevRefBrowser::GetGitRevRefMap(refMap, 0, err, [](const CString& refName) { return CStringUtils::StartsWith(refName, L"refs/heads/"); }));
	EXPECT_STREQ(L"", err);
	EXPECT_EQ(6U, refMap.size());
	EXPECT_TRUE(refMap.find(L"refs/heads/master") != refMap.end());
	for (auto it = refMap.cbegin(); it != refMap.cend(); ++it)
		EXPECT_TRUE(CStringUtils::StartsWith(it->first, L"refs/heads/"));

	refMap.clear();
	EXPECT_EQ(0, GitRevRefBrowser::GetGitRevRefMap(refMap, 1, err));
	EXPECT_STREQ(L"", err);
	EXPECT_EQ(6U, refMap.size());
	for (const auto& branch : { L"refs/heads/master", L"refs/heads/master2", L"refs/remotes/origin/master", L"refs/tags/all-files-signed", L"refs/tags/also-signed", L"refs/tags/normal-tag" })
		EXPECT_TRUE(refMap.find(branch) != refMap.end());

	refMap.clear();
	EXPECT_EQ(0, GitRevRefBrowser::GetGitRevRefMap(refMap, 2, err));
	EXPECT_STREQ(L"", err);
	EXPECT_EQ(6U, refMap.size());
	EXPECT_TRUE(refMap.find(L"refs/heads/master") == refMap.end());
	for (const auto& branch : { L"refs/heads/forconflict", L"refs/heads/signed-commit", L"refs/heads/simple-conflict", L"refs/heads/subdir/branch", L"refs/notes/commits", L"refs/stash" })
		EXPECT_TRUE(refMap.find(branch) != refMap.end());
}
Example #3
0
TEST(TestStringUtils, SplitString)
{
  CStdStringArray varresults;

  EXPECT_EQ(9, StringUtils::SplitString("a,b,c,de,,,fg,,", ",", varresults));
  EXPECT_STREQ("a", varresults.at(0).c_str());
  EXPECT_STREQ("b", varresults.at(1).c_str());
  EXPECT_STREQ("c", varresults.at(2).c_str());
  EXPECT_STREQ("de", varresults.at(3).c_str());
  EXPECT_STREQ("", varresults.at(4).c_str());
  EXPECT_STREQ("", varresults.at(5).c_str());
  EXPECT_STREQ("fg", varresults.at(6).c_str());
  EXPECT_STREQ("", varresults.at(7).c_str());
  EXPECT_STREQ("", varresults.at(8).c_str());

  varresults.clear();
  varresults = StringUtils::SplitString("g,h,ij,k,lm,,n", ",");
  EXPECT_STREQ("g", varresults.at(0).c_str());
  EXPECT_STREQ("h", varresults.at(1).c_str());
  EXPECT_STREQ("ij", varresults.at(2).c_str());
  EXPECT_STREQ("k", varresults.at(3).c_str());
  EXPECT_STREQ("lm", varresults.at(4).c_str());
  EXPECT_STREQ("", varresults.at(5).c_str());
  EXPECT_STREQ("n", varresults.at(6).c_str());
}
TEST_F(LinkedListTest, GetTest) {
    EXPECT_STREQ("michael", (char *) list->get(0));
    EXPECT_STREQ("john", (char *) list->get(1));
}
TEST_F(LinkedListTest, SetTest) {
    list->set(0, name3);
    EXPECT_STREQ("matthew", (char *) list->get(0));
    list->set(1, name3);
    EXPECT_STREQ("matthew", (char *) list->get(1));
}
Example #6
0
/**
 * @brief TEST_F SdkTestNodeOperations
 *
 * It performs different operations with nodes, assuming the Cloud folder is empty at the beginning.
 *
 * - Create a new folder
 * - Rename a node
 * - Copy a node
 * - Get child nodes of given node
 * - Get child node by name
 * - Get node by path
 * - Get node by name
 * - Move a node
 * - Get parent node
 * - Move a node to Rubbish bin
 * - Remove a node
 */
TEST_F(SdkTest, SdkTestNodeOperations)
{
    // --- Create a new folder ---

    MegaNode *rootnode = megaApi->getRootNode();
    char name1[64] = "New folder";

    responseReceived = false;
    megaApi->createFolder(name1, rootnode);
    waitForResponse(&responseReceived);

    ASSERT_EQ(MegaError::API_OK, lastError) << "Cannot create a folder (error: " << lastError << ")";


    // --- Rename a node ---

    MegaNode *n1 = megaApi->getNodeByHandle(h);
    strcpy(name1, "Folder renamed");

    responseReceived = false;
    megaApi->renameNode(n1, name1);
    waitForResponse(&responseReceived);

    ASSERT_EQ(MegaError::API_OK, lastError) << "Cannot rename a node (error: " << lastError << ")";


    // --- Copy a node ---

    MegaNode *n2;
    char name2[64] = "Folder copy";

    responseReceived = false;
    megaApi->copyNode(n1, rootnode, name2);
    waitForResponse(&responseReceived);

    ASSERT_EQ(MegaError::API_OK, lastError) << "Cannot create a copy of a node (error: " << lastError << ")";
    n2 = megaApi->getNodeByHandle(h);


    // --- Get child nodes ---

    MegaNodeList *children;
    children = megaApi->getChildren(rootnode);

    EXPECT_EQ(megaApi->getNumChildren(rootnode), children->size()) << "Wrong number of child nodes";
    ASSERT_LE(2, children->size()) << "Wrong number of children nodes found";
    EXPECT_STREQ(name2, children->get(0)->getName()) << "Wrong name of child node"; // "Folder copy"
    EXPECT_STREQ(name1, children->get(1)->getName()) << "Wrong name of child node"; // "Folder rename"

    delete children;


    // --- Get child node by name ---

    MegaNode *n3;
    n3 = megaApi->getChildNode(rootnode, name2);

    bool null_pointer = (n3 == NULL);
    EXPECT_FALSE(null_pointer) << "Child node by name not found";
//    ASSERT_EQ(n2->getHandle(), n3->getHandle());  This test may fail due to multiple nodes with the same name


    // --- Get node by path ---

    char path[128] = "/Folder copy";
    MegaNode *n4;
    n4 = megaApi->getNodeByPath(path);

    null_pointer = (n4 == NULL);
    EXPECT_FALSE(null_pointer) << "Node by path not found";


    // --- Search for a node ---
    MegaNodeList *nlist;
    nlist = megaApi->search(rootnode, "copy");

    ASSERT_EQ(1, nlist->size());
    EXPECT_EQ(n4->getHandle(), nlist->get(0)->getHandle()) << "Search node by pattern failed";

    delete nlist;


    // --- Move a node ---

    responseReceived = false;
    megaApi->moveNode(n1, n2);
    waitForResponse(&responseReceived);

    ASSERT_EQ(MegaError::API_OK, lastError) << "Cannot move node (error: " << lastError << ")";


    // --- Get parent node ---

    MegaNode *n5;
    n5 = megaApi->getParentNode(n1);

    ASSERT_EQ(n2->getHandle(), n5->getHandle()) << "Wrong parent node";


    // --- Send to Rubbish bin ---

    responseReceived = false;
    megaApi->moveNode(n2, megaApi->getRubbishNode());
    waitForResponse(&responseReceived);

    ASSERT_EQ(MegaError::API_OK, lastError) << "Cannot move node to Rubbish bin (error: " << lastError << ")";


    // --- Remove a node ---

    responseReceived = false;
    megaApi->remove(n2);
    waitForResponse(&responseReceived);

    ASSERT_EQ(MegaError::API_OK, lastError) << "Cannot remove a node (error: " << lastError << ")";

    delete rootnode;
    delete n1;
    delete n2;
    delete n3;
    delete n4;
    delete n5;
}
Example #7
0
TEST_F(numtoaTest, Address) {
	u_int32 input = htonl(3221225472UL+512UL+1UL); // 192.0.2.1

	EXPECT_STREQ("192.0.2.1", numtoa(input));
}
Example #8
0
TEST_F(KeyboardTest, TestCtrlReturn)
{
    EXPECT_STREQ("InsertNewline", interpretCtrlKeyPress(0xD));
}
Example #9
0
TEST_F(KeyboardTest, TestOSModifierY)
{
#if !OS(MACOSX)
    EXPECT_STREQ("Redo", interpretOSModifierKeyPress('Y'));
#endif
}
TEST_F(InputMethodControllerTest, BackspaceFromEndOfInput)
{
    HTMLInputElement* input = toHTMLInputElement(
        insertHTMLElement("<input id='sample'>", "sample"));

    input->setValue("fooX");
    controller().setEditableSelectionOffsets(PlainTextRange(4, 4));
    EXPECT_STREQ("fooX", input->value().utf8().data());
    controller().extendSelectionAndDelete(0, 0);
    EXPECT_STREQ("fooX", input->value().utf8().data());

    input->setValue("fooX");
    controller().setEditableSelectionOffsets(PlainTextRange(4, 4));
    EXPECT_STREQ("fooX", input->value().utf8().data());
    controller().extendSelectionAndDelete(1, 0);
    EXPECT_STREQ("foo", input->value().utf8().data());

    input->setValue(String::fromUTF8("foo\xE2\x98\x85")); // U+2605 == "black star"
    controller().setEditableSelectionOffsets(PlainTextRange(4, 4));
    EXPECT_STREQ("foo\xE2\x98\x85", input->value().utf8().data());
    controller().extendSelectionAndDelete(1, 0);
    EXPECT_STREQ("foo", input->value().utf8().data());

    input->setValue(String::fromUTF8("foo\xF0\x9F\x8F\x86")); // U+1F3C6 == "trophy"
    controller().setEditableSelectionOffsets(PlainTextRange(4, 4));
    EXPECT_STREQ("foo\xF0\x9F\x8F\x86", input->value().utf8().data());
    controller().extendSelectionAndDelete(1, 0);
    EXPECT_STREQ("foo", input->value().utf8().data());

    input->setValue(String::fromUTF8("foo\xE0\xB8\x81\xE0\xB9\x89")); // composed U+0E01 "ka kai" + U+0E49 "mai tho"
    controller().setEditableSelectionOffsets(PlainTextRange(4, 4));
    EXPECT_STREQ("foo\xE0\xB8\x81\xE0\xB9\x89", input->value().utf8().data());
    controller().extendSelectionAndDelete(1, 0);
    EXPECT_STREQ("foo", input->value().utf8().data());

    input->setValue("fooX");
    controller().setEditableSelectionOffsets(PlainTextRange(4, 4));
    EXPECT_STREQ("fooX", input->value().utf8().data());
    controller().extendSelectionAndDelete(0, 1);
    EXPECT_STREQ("fooX", input->value().utf8().data());
}
/* ****************************************************************************
*
* restErrorReplyGet - 
*/
TEST(restReply, restErrorReplyGet)
{
  const char* rcrOutfile01   = "ngsi9.restReply.registerContext01.ok.valid.xml";
  const char* rcrOutfile02   = "ngsi9.restReply.registerContext02.ok.valid.xml";
  const char* dcarOutfile01  = "ngsi9.restReply.discovery01.ok.valid.xml";
  const char* dcarOutfile02  = "ngsi9.restReply.discovery02.ok.valid.xml";
  const char* scarOutfile01  = "ngsi9.restReply.subscribeContextAvailability01.ok.valid.xml";
  const char* scarOutfile02  = "ngsi9.restReply.subscribeContextAvailability02.ok.valid.xml";
  const char* ucasOutfile01  = "ngsi9.restReply.updateContextAvailabilitySubscription01.ok.valid.xml";
  const char* ucasOutfile02  = "ngsi9.restReply.updateContextAvailabilitySubscription02.ok.valid.xml";
  const char* ucarOutfile01  = "ngsi9.restReply.unsubscribeContextAvailability01.ok.valid.xml";
  const char* ucarOutfile02  = "ngsi9.restReply.unsubscribeContextAvailability02.ok.valid.xml";
  const char* ncarOutfile01  = "ngsi9.restReply.notifyContextAvailabilityRequest01.ok.valid.xml";
  const char* ncarOutfile02  = "ngsi9.restReply.notifyContextAvailabilityRequest02.ok.valid.xml";
  const char* qcrOutfile01   = "ngsi10.restReply.queryContextResponse01.ok.valid.xml";
  const char* qcrOutfile02   = "ngsi10.restReply.queryContextResponse02.ok.valid.xml";
  const char* scrOutfile01   = "ngsi10.restReply.subscribeContextResponse01.ok.valid.xml";
  const char* scrOutfile02   = "ngsi10.restReply.subscribeContextResponse02.ok.valid.xml";
  const char* ucsOutfile01   = "ngsi10.restReply.updateContextSubscriptionResponse01.ok.valid.xml";
  const char* ucsOutfile02   = "ngsi10.restReply.updateContextSubscriptionResponse02.ok.valid.xml";
  const char* uscrOutfile01  = "ngsi10.restReply.unsubscribeContextResponse01.ok.valid.xml";
  const char* uscrOutfile02  = "ngsi10.restReply.unsubscribeContextResponse02.ok.valid.xml";
  const char* ucrOutfile01   = "ngsi10.restReply.updateContextResponse01.ok.valid.xml";
  const char* ucrOutfile02   = "ngsi10.restReply.updateContextResponse02.ok.valid.xml";
  const char* ncrOutfile01   = "ngsi10.restReply.notifyContextResponse01.ok.valid.xml";
  const char* ncrOutfile02   = "ngsi10.restReply.notifyContextResponse02.ok.valid.xml";

  std::string rcr1 = "registerContext";
  std::string rcr2 = "/ngsi9/registerContext";
  std::string rcr3 = "/NGSI9/registerContext";
  std::string rcr4 = "registerContextRequest";

  std::string dcar1 = "discoverContextAvailability";
  std::string dcar2 = "/ngsi9/discoverContextAvailability";
  std::string dcar3 = "/NGSI9/discoverContextAvailability";
  std::string dcar4 = "discoverContextAvailabilityRequest";

  std::string scar1 = "subscribeContextAvailability";
  std::string scar2 = "/ngsi9/subscribeContextAvailability";
  std::string scar3 = "/NGSI9/subscribeContextAvailability";
  std::string scar4 = "subscribeContextAvailabilityRequest";

  std::string ucas1 = "updateContextAvailabilitySubscription";
  std::string ucas2 = "/ngsi9/updateContextAvailabilitySubscription";
  std::string ucas3 = "/NGSI9/updateContextAvailabilitySubscription";
  std::string ucas4 = "updateContextAvailabilitySubscriptionRequest";
  
  std::string ucar1 = "unsubscribeContextAvailability";
  std::string ucar2 = "/ngsi9/unsubscribeContextAvailability";
  std::string ucar3 = "/NGSI9/unsubscribeContextAvailability";
  std::string ucar4 = "unsubscribeContextAvailabilityRequest";
  
  std::string ncar1 = "notifyContextAvailability";
  std::string ncar2 = "/ngsi9/notifyContextAvailability";
  std::string ncar3 = "/NGSI9/notifyContextAvailability";
  std::string ncar4 = "notifyContextAvailabilityRequest";
  
  std::string qcr1 = "queryContext";
  std::string qcr2 = "/ngsi10/queryContext";
  std::string qcr3 = "/NGSI10/queryContext";
  std::string qcr4 = "queryContextRequest";
  
  std::string scr1 = "subscribeContext";
  std::string scr2 = "/ngsi10/subscribeContext";
  std::string scr3 = "/NGSI10/subscribeContext";
  std::string scr4 = "subscribeContextRequest";
  
  std::string ucs1 = "updateContextSubscription";
  std::string ucs2 = "/ngsi10/updateContextSubscription";
  std::string ucs3 = "/NGSI10/updateContextSubscription";
  std::string ucs4 = "updateContextSubscriptionRequest";
  
  std::string uscr1 = "unsubscribeContext";
  std::string uscr2 = "/ngsi10/unsubscribeContext";
  std::string uscr3 = "/NGSI10/unsubscribeContext";
  std::string uscr4 = "unsubscribeContextRequest";
  
  std::string ucr1 = "updateContext";
  std::string ucr2 = "/ngsi10/updateContext";
  std::string ucr3 = "/NGSI10/updateContext";
  std::string ucr4 = "updateContextRequest";
  
  std::string ncr1 = "notifyContext";
  std::string ncr2 = "/ngsi10/notifyContext";
  std::string ncr3 = "/NGSI10/notifyContext";
  std::string ncr4 = "notifyContextRequest";
  
  std::string     out;
  ConnectionInfo  ci("/ngsi/test", "POST", "1.1");
  
  utInit();

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), rcrOutfile01)) << "Error getting test data from '" << rcrOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", rcr1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", rcr2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", rcr3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", rcr4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), rcrOutfile02)) << "Error getting test data from '" << rcrOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", rcr1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", rcr2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", rcr3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", rcr4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), dcarOutfile01)) << "Error getting test data from '" << dcarOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", dcar1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", dcar2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", dcar3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", dcar4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), dcarOutfile02)) << "Error getting test data from '" << dcarOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", dcar1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", dcar2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", dcar3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", dcar4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), scarOutfile01)) << "Error getting test data from '" << scarOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", scar1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scar2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scar3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scar4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), scarOutfile02)) << "Error getting test data from '" << scarOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", scar1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scar2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scar3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scar4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucasOutfile01)) << "Error getting test data from '" << ucasOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucas1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucas2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucas3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucas4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucasOutfile02)) << "Error getting test data from '" << ucasOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucas1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucas2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucas3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucas4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucarOutfile01)) << "Error getting test data from '" << ucarOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucar1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucar2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucar3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucar4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucarOutfile02)) << "Error getting test data from '" << ucarOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucar1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucar2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucar3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucar4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ncarOutfile01)) << "Error getting test data from '" << ncarOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", ncar1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncar2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncar3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncar4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ncarOutfile02)) << "Error getting test data from '" << ncarOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", ncar1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncar2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncar3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncar4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), qcrOutfile01)) << "Error getting test data from '" << qcrOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", qcr1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", qcr2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", qcr3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", qcr4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), qcrOutfile02)) << "Error getting test data from '" << qcrOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", qcr1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", qcr2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", qcr3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", qcr4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), scrOutfile01)) << "Error getting test data from '" << scrOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", scr1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scr2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scr3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scr4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), scrOutfile02)) << "Error getting test data from '" << scrOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", scr1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scr2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scr3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", scr4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucsOutfile01)) << "Error getting test data from '" << ucsOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucs1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucs2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucs3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucs4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucsOutfile02)) << "Error getting test data from '" << ucsOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucs1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucs2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucs3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucs4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), uscrOutfile01)) << "Error getting test data from '" << uscrOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", uscr1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", uscr2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", uscr3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", uscr4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), uscrOutfile02)) << "Error getting test data from '" << uscrOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", uscr1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", uscr2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", uscr3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", uscr4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucrOutfile01)) << "Error getting test data from '" << ucrOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucr1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  out = restErrorReplyGet(&ci, XML, "", ucr2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucr3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucr4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ucrOutfile02)) << "Error getting test data from '" << ucrOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", ucr1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucr2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucr3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ucr4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());


  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ncrOutfile01)) << "Error getting test data from '" << ncrOutfile01 << "'";
  out = restErrorReplyGet(&ci, XML, "", ncr1, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncr2, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncr3, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncr4, SccOk, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  EXPECT_EQ("OK", testDataFromFile(expectedBuf, sizeof(expectedBuf), ncrOutfile02)) << "Error getting test data from '" << ncrOutfile02 << "'";
  out = restErrorReplyGet(&ci, XML, "", ncr1, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncr2, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncr3, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());
  out = restErrorReplyGet(&ci, XML, "", ncr4, SccBadRequest, "detail");
  EXPECT_STREQ(expectedBuf, out.c_str());

  utExit();
}
Example #12
0
TEST(stdio, snprintf_negative_zero_5084292) {
  char buf[BUFSIZ];

  snprintf(buf, sizeof(buf), "%f", -0.0);
  EXPECT_STREQ("-0.000000", buf);
}
Example #13
0
TEST(stdio, snprintf_lld_LLONG_MIN) {
  char buf[BUFSIZ];
  snprintf(buf, sizeof(buf), "%lld", LLONG_MIN);
  EXPECT_STREQ("-9223372036854775808", buf);
}
Example #14
0
TEST(stdio, snprintf_d_INT_MIN) {
  char buf[BUFSIZ];
  snprintf(buf, sizeof(buf), "%d", INT_MIN);
  EXPECT_STREQ("-2147483648", buf);
}
Example #15
0
TEST_F(KeyboardTest, TestInsertNewline3)
{
    EXPECT_STREQ("InsertNewline", interpretNewLine(WebInputEvent::AltKey));
}
Example #16
0
TEST_F(KeyboardTest, TestOSModifierA)
{
#if !OS(MACOSX)
    EXPECT_STREQ("SelectAll", interpretOSModifierKeyPress('A'));
#endif
}
Example #17
0
TEST_F(KeyboardTest, TestInsertNewline4)
{
    int modifiers = WebInputEvent::AltKey | WebInputEvent::ShiftKey;
    const char* result = interpretNewLine(modifiers);
    EXPECT_STREQ("InsertNewline", result);
}
Example #18
0
TEST_F(KeyboardTest, TestOSModifierC)
{
#if !OS(MACOSX)
    EXPECT_STREQ("Copy", interpretOSModifierKeyPress('C'));
#endif
}
Example #19
0
/**
 * @brief TEST_F SdkTestContacts
 *
 * Creates an auxiliar 'MegaApi' object to interact with the main MEGA account.
 *
 * - Invite a contact
 * = Ignore the invitation
 * - Delete the invitation
 *
 * - Invite a contact
 * = Deny the invitation
 *
 * - Invite a contact
 * = Accept the invitation
 *
 * - Remove contact
 *
 * TODO:
 * - Invite a contact not registered in MEGA yet (requires validation of account)
 * - Remind an existing invitation (requires 2 weeks wait)
 */
TEST_F(SdkTest, SdkTestContacts)
{
    ASSERT_NO_FATAL_FAILURE( getMegaApiAux() );    // login + fetchnodes


    // --- Check my email and the email of the contact ---

    EXPECT_STREQ(email.data(), megaApi->getMyEmail());
    EXPECT_STREQ(emailaux.data(), megaApiAux->getMyEmail());


    // --- Send a new contact request ---

    string message = "Hi contact. This is a testing message";

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_ADD) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)


    // --- Check the sent contact request ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(true) );

    ASSERT_STREQ(message.data(), cr->getSourceMessage()) << "Message sent is corrupted";
    ASSERT_STREQ(email.data(), cr->getSourceEmail()) << "Wrong source email";
    ASSERT_STREQ(emailaux.data(), cr->getTargetEmail()) << "Wrong target email";
    ASSERT_EQ(MegaContactRequest::STATUS_UNRESOLVED, cr->getStatus()) << "Wrong contact request status";
    ASSERT_TRUE(cr->isOutgoing()) << "Wrong direction of the contact request";

    delete cr;
    cr = NULL;


    // --- Check received contact request ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    ASSERT_STREQ(message.data(), craux->getSourceMessage()) << "Message received is corrupted";
    ASSERT_STREQ(email.data(), craux->getSourceEmail()) << "Wrong source email";
    ASSERT_STREQ(NULL, craux->getTargetEmail()) << "Wrong target email";    // NULL according to MegaApi documentation
    ASSERT_EQ(MegaContactRequest::STATUS_UNRESOLVED, craux->getStatus()) << "Wrong contact request status";
    ASSERT_FALSE(craux->isOutgoing()) << "Wrong direction of the contact request";

    delete craux;
    craux = NULL;


    // --- Ignore received contact request ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    contactRequestUpdatedAux = false;
    ASSERT_NO_FATAL_FAILURE( replyContact(craux, MegaContactRequest::REPLY_ACTION_IGNORE) );
    waitForResponse(&contactRequestUpdatedAux); // only at auxiliar account. Main account is not notified

    delete craux;
    craux = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;


    // --- Cancel the invitation ---

    message = "I don't wanna be your contact anymore";

    contactRequestUpdated = false;
    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_DELETE) );
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;

    // The target contact doesn't receive notification, since the invitation was ignored previously


    // --- Remind a contact invitation (cannot until 2 weeks after invitation/last reminder) ---

//    contactRequestReceived = false;
//    megaApi->inviteContact(emailaux.data(), message.data(), MegaContactRequest::INVITE_ACTION_REMIND);
//    waitForResponse(&contactRequestReceived, 30); // at the target side (auxiliar account)

//    ASSERT_TRUE(contactRequestReceived) << "Contact invitation reminder not received after " << timeout  << " seconds";


    // --- Invite a new contact (again) ---

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_ADD) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)


    // --- Deny a contact invitation ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    replyContact(craux, MegaContactRequest::REPLY_ACTION_DENY);

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)

    delete craux;
    craux = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(true, 0) );
    delete cr;
    cr = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;


    // --- Invite a new contact (again) ---

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( inviteContact(emailaux, message, MegaContactRequest::INVITE_ACTION_ADD) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)


    // --- Accept a contact invitation ---

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false) );

    contactRequestUpdated = false;
    contactRequestUpdatedAux = false;

    ASSERT_NO_FATAL_FAILURE( replyContact(craux, MegaContactRequest::REPLY_ACTION_ACCEPT) );

    waitForResponse(&contactRequestUpdatedAux); // at the target side (auxiliar account)
    waitForResponse(&contactRequestUpdated);    // at the source side (main account)

    delete craux;
    craux = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(true, 0) );
    delete cr;
    cr = NULL;

    ASSERT_NO_FATAL_FAILURE( getContactRequest(false, 0) );
    delete craux;
    craux = NULL;


    // --- Delete an existing contact ---

    contactRemoved = false;
    ASSERT_NO_FATAL_FAILURE( removeContact(emailaux) );
    waitForResponse(&contactRemoved);

    MegaUser *u = megaApi->getContact(emailaux.data());
    ASSERT_EQ(MegaUser::VISIBILITY_HIDDEN, u->getVisibility()) << "New contact still visible";
    delete u;
}
Example #20
0
TEST_F(KeyboardTest, TestOSModifierV)
{
#if !OS(MACOSX)
    EXPECT_STREQ("Paste", interpretOSModifierKeyPress('V'));
#endif
}
TEST_F(PublicMethodsEmbedderTest, MakeFormatDate) {
  v8::Isolate::Scope isolate_scope(isolate());
  v8::HandleScope handle_scope(isolate());
  v8::Context::Scope context_scope(GetV8Context());
  CFX_WideString formatted_date;

  // 1968-06-25
  formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"ddmmyy");
  EXPECT_STREQ(L"250668", formatted_date.c_str());
  formatted_date = CJS_PublicMethods::MakeFormatDate(-47952000000, L"yy/mm/dd");
  EXPECT_STREQ(L"68/06/25", formatted_date.c_str());

  // 1969-12-31
  formatted_date = CJS_PublicMethods::MakeFormatDate(-0.0001, L"ddmmyy");
  EXPECT_STREQ(L"311269", formatted_date.c_str());
  formatted_date = CJS_PublicMethods::MakeFormatDate(-0.0001, L"yy!mmdd");
  EXPECT_STREQ(L"69!1231", formatted_date.c_str());

  // 1970-01-01
  formatted_date = CJS_PublicMethods::MakeFormatDate(0, L"ddmmyy");
  EXPECT_STREQ(L"010170", formatted_date.c_str());
  formatted_date = CJS_PublicMethods::MakeFormatDate(0, L"mm-yyyy-dd");
  EXPECT_STREQ(L"01-1970-01", formatted_date.c_str());

  // 1985-12-31
  formatted_date = CJS_PublicMethods::MakeFormatDate(504835200000.0, L"ddmmyy");
  EXPECT_STREQ(L"311285", formatted_date.c_str());
  formatted_date = CJS_PublicMethods::MakeFormatDate(504835200000.0, L"yymmdd");
  EXPECT_STREQ(L"851231", formatted_date.c_str());

  // 1995-02-01
  formatted_date = CJS_PublicMethods::MakeFormatDate(791596800000.0, L"ddmmyy");
  EXPECT_STREQ(L"010295", formatted_date.c_str());
  formatted_date =
      CJS_PublicMethods::MakeFormatDate(791596800000.0, L"yyyymmdd");
  EXPECT_STREQ(L"19950201", formatted_date.c_str());

  // 2005-02-01
  formatted_date =
      CJS_PublicMethods::MakeFormatDate(1107216000000.0, L"ddmmyy");
  EXPECT_STREQ(L"010205", formatted_date.c_str());
  formatted_date =
      CJS_PublicMethods::MakeFormatDate(1107216000000.0, L"yyyyddmm");
  EXPECT_STREQ(L"20050102", formatted_date.c_str());

  // 2085-12-31
  formatted_date =
      CJS_PublicMethods::MakeFormatDate(3660595200000.0, L"ddmmyy");
  EXPECT_STREQ(L"311285", formatted_date.c_str());
  formatted_date =
      CJS_PublicMethods::MakeFormatDate(3660595200000.0, L"yyyydd");
  EXPECT_STREQ(L"208531", formatted_date.c_str());

  // 2095-02-01
  formatted_date =
      CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"ddmmyy");
  EXPECT_STREQ(L"010295", formatted_date.c_str());
  formatted_date =
      CJS_PublicMethods::MakeFormatDate(3947356800000.0, L"mmddyyyy");
  EXPECT_STREQ(L"02012095", formatted_date.c_str());
}
Example #22
0
TEST_F(KeyboardTest, TestInsertTab)
{
    EXPECT_STREQ("InsertTab", interpretTab(noModifiers));
}
TEST_F(LinkedListTest, AppendTest) {
    list->append(name3);

    EXPECT_STREQ("matthew", (char *) list->get(2));
}
Example #24
0
TEST_F(KeyboardTest, TestInsertBackTab)
{
    EXPECT_STREQ("InsertBacktab", interpretTab(WebInputEvent::ShiftKey));
}
Example #25
0
TEST_F(lagi_mru, add_entry) {
	agi::fs::Copy("data/mru_ok.json", "data/mru_tmp");
	agi::MRUManager mru("data/mru_tmp", default_mru);
	EXPECT_NO_THROW(mru.Add("Valid", "/path/to/file"));
	EXPECT_STREQ("/path/to/file", mru.Get("Valid")->front().string().c_str());
}
Example #26
0
TEST_F(KeyboardTest, TestInsertNewline)
{
    EXPECT_STREQ("InsertNewline", interpretNewLine(noModifiers));
}
Example #27
0
TEST(TestStringUtils, EmptyString)
{
  EXPECT_STREQ("", StringUtils::EmptyString.c_str());
}
Example #28
0
TEST_F(KeyboardTest, TestInsertLineBreak)
{
    EXPECT_STREQ("InsertLineBreak", interpretNewLine(WebInputEvent::ShiftKey));
}
Example #29
0
TEST(TestRarFile, NormalRAR)
{
  XFILE::CFile file;
  char buf[20];
  memset(&buf, 0, sizeof(buf));
  CStdString reffile, strrarpath, strpathinrar;
  CFileItemList itemlist, itemlistemptydir;
  struct __stat64 stat_buffer;

  reffile = XBMC_REF_FILE_PATH("xbmc/filesystem/test/refRARnormal.rar");
  URIUtils::CreateArchivePath(strrarpath, "rar", reffile, "");
  ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strrarpath, itemlist));
  itemlist.Sort(SortByPath, SortOrderAscending);

  /* /reffile.txt */
  strpathinrar = itemlist[1]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/reffile.txt"));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFREG);

  ASSERT_TRUE(file.Open(strpathinrar));
  EXPECT_EQ(0, file.GetPosition());
  EXPECT_EQ(1616, file.GetLength());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_TRUE(file.ReadString(buf, sizeof(buf)));
  EXPECT_EQ(39, file.GetPosition());
  EXPECT_STREQ("an award-winning fr", buf);
  EXPECT_EQ(100, file.Seek(100));
  EXPECT_EQ(100, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(120, file.GetPosition());
  EXPECT_TRUE(!memcmp("ent hub for digital ", buf, sizeof(buf) - 1));
  EXPECT_EQ(220, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(220, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(240, file.GetPosition());
  EXPECT_TRUE(!memcmp("rs, XBMC is a non-pr", buf, sizeof(buf) - 1));
  EXPECT_EQ(1596, file.Seek(-(int64_t)sizeof(buf), SEEK_END));
  EXPECT_EQ(1596, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(1616, file.GetPosition());
  EXPECT_TRUE(!memcmp("multimedia jukebox.\n", buf, sizeof(buf) - 1));
  EXPECT_EQ(1716, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(1716, file.GetPosition());
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(-1, file.Seek(-100, SEEK_SET));
  file.Close();

  /* /testsymlink -> testdir/reffile.txt */
  strpathinrar = itemlist[2]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testsymlink"));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFLNK);

  /*
   * FIXME: Reading symlinks in RARs is currently broken. It takes a long time
   * to read them and they produce erroneous results. The expected result is
   * the target paths of the symlinks.
   */
  ASSERT_TRUE(file.Open(strpathinrar));
  EXPECT_EQ(19, file.GetLength());
  file.Close();

  /* /testsymlinksubdir -> testdir/testsubdir/reffile.txt */
  strpathinrar = itemlist[3]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testsymlinksubdir"));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFLNK);

  ASSERT_TRUE(file.Open(strpathinrar));
  EXPECT_EQ(30, file.GetLength());
  file.Close();

  /* /testdir/ */
  strpathinrar = itemlist[0]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testdir/"));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFDIR);

  itemlist.Clear();
  ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist));
  itemlist.Sort(SortByPath, SortOrderAscending);

  /* /testdir/reffile.txt */
  strpathinrar = itemlist[1]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testdir/reffile.txt",
                                    true));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFREG);

  ASSERT_TRUE(file.Open(strpathinrar));
  EXPECT_EQ(0, file.GetPosition());
  EXPECT_EQ(1616, file.GetLength());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_TRUE(file.ReadString(buf, sizeof(buf)));
  EXPECT_EQ(39, file.GetPosition());
  EXPECT_STREQ("an award-winning fr", buf);
  EXPECT_EQ(100, file.Seek(100));
  EXPECT_EQ(100, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(120, file.GetPosition());
  EXPECT_TRUE(!memcmp("ent hub for digital ", buf, sizeof(buf) - 1));
  EXPECT_EQ(220, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(220, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(240, file.GetPosition());
  EXPECT_TRUE(!memcmp("rs, XBMC is a non-pr", buf, sizeof(buf) - 1));
  EXPECT_EQ(1596, file.Seek(-(int64_t)sizeof(buf), SEEK_END));
  EXPECT_EQ(1596, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(1616, file.GetPosition());
  EXPECT_TRUE(!memcmp("multimedia jukebox.\n", buf, sizeof(buf) - 1));
  EXPECT_EQ(1716, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(1716, file.GetPosition());
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(-1, file.Seek(-100, SEEK_SET));
  file.Close();

  /* /testdir/testemptysubdir */
  strpathinrar = itemlist[2]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testdir/testemptysubdir",
                                    true));
  /* TODO: Should this set the itemlist to an empty list instead? */
  EXPECT_FALSE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlistemptydir));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFDIR);

  /* FIXME: This directory appears a second time as a file */
  strpathinrar = itemlist[3]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testdir/testsubdir"));

  /* /testdir/testsymlink -> testsubdir/reffile.txt */
  strpathinrar = itemlist[4]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testdir/testsymlink",
                                    true));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFLNK);

  ASSERT_TRUE(file.Open(strpathinrar));
  EXPECT_EQ(22, file.GetLength());
  file.Close();

  /* /testdir/testsubdir/ */
  strpathinrar = itemlist[0]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar, "/testdir/testsubdir/",
                                    true));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFDIR);

  itemlist.Clear();
  ASSERT_TRUE(XFILE::CDirectory::GetDirectory(strpathinrar, itemlist));
  itemlist.Sort(SortByPath, SortOrderAscending);

  /* /testdir/testsubdir/reffile.txt */
  strpathinrar = itemlist[0]->GetPath();
  ASSERT_TRUE(StringUtils::EndsWith(strpathinrar,
                                    "/testdir/testsubdir/reffile.txt", true));
  EXPECT_EQ(0, XFILE::CFile::Stat(strpathinrar, &stat_buffer));
  EXPECT_TRUE((stat_buffer.st_mode & S_IFMT) | S_IFREG);

  ASSERT_TRUE(file.Open(strpathinrar));
  EXPECT_EQ(0, file.GetPosition());
  EXPECT_EQ(1616, file.GetLength());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_TRUE(file.ReadString(buf, sizeof(buf)));
  EXPECT_EQ(39, file.GetPosition());
  EXPECT_STREQ("an award-winning fr", buf);
  EXPECT_EQ(100, file.Seek(100));
  EXPECT_EQ(100, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(120, file.GetPosition());
  EXPECT_TRUE(!memcmp("ent hub for digital ", buf, sizeof(buf) - 1));
  EXPECT_EQ(220, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(220, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(240, file.GetPosition());
  EXPECT_TRUE(!memcmp("rs, XBMC is a non-pr", buf, sizeof(buf) - 1));
  EXPECT_EQ(1596, file.Seek(-(int64_t)sizeof(buf), SEEK_END));
  EXPECT_EQ(1596, file.GetPosition());
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(1616, file.GetPosition());
  EXPECT_TRUE(!memcmp("multimedia jukebox.\n", buf, sizeof(buf) - 1));
  EXPECT_EQ(1716, file.Seek(100, SEEK_CUR));
  EXPECT_EQ(1716, file.GetPosition());
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(sizeof(buf), file.Read(buf, sizeof(buf)));
  file.Flush();
  EXPECT_EQ(20, file.GetPosition());
  EXPECT_TRUE(!memcmp("About\n-----\nXBMC is ", buf, sizeof(buf) - 1));
  EXPECT_EQ(0, file.Seek(0, SEEK_SET));
  EXPECT_EQ(-1, file.Seek(-100, SEEK_SET));
  file.Close();
}
Example #30
0
TEST(stdio, snprintf_lc) {
  char buf[BUFSIZ];
  wint_t wc = L'a';
  EXPECT_EQ(3, snprintf(buf, sizeof(buf), "<%lc>", wc));
  EXPECT_STREQ("<a>", buf);
}