~ubuntu-branches/ubuntu/oneiric/mozc/oneiric

« back to all changes in this revision

Viewing changes to base/util_test.cc

  • Committer: Bazaar Package Importer
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2010-07-14 03:26:47 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100714032647-13qjisj6m8cm8jdx
Tags: 0.12.410.102-1
* New upstream release (Closes: #588971).
  - Add mozc-server, mozc-utils-gui and scim-mozc packages.
* Update debian/rules.
  Add --gypdir option to build_mozc.py.
* Update debian/control.
  - Bumped standards-version to 3.9.0.
  - Update description.
* Add mozc icon (Closes: #588972).
* Add patch which revises issue 18.
  ibus_mozc_issue18.patch
* kFreeBSD build support.
  support_kfreebsd.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 public:
47
47
  virtual void Run() {
48
48
    for (int i = 0; i < 3; ++i) {
49
 
#ifdef COMPILER_MSVC
50
 
      Sleep(1000);
51
 
#else
52
 
      sleep(1);
53
 
#endif
 
49
      Util::Sleep(1000);
54
50
    }
55
51
  }
56
52
};
1485
1481
}
1486
1482
 
1487
1483
TEST(UtilTest, WriteByteArray) {
1488
 
  ostringstream os;
1489
 
  const string name = "Test";
1490
 
  char buf[] = "mozc";
1491
 
  size_t buf_size = sizeof(buf);
1492
 
  Util::WriteByteArray(name, buf, buf_size, &os);
1493
 
  EXPECT_NE(os.str().find("static const size_t kTestSize ="), string::npos);
1494
 
#ifdef OS_WINDOWS
1495
 
  EXPECT_NE(os.str().find("static const uint64 kTestUint64[] ="),
1496
 
            string::npos);
1497
 
  EXPECT_NE(os.str().find("static const char *kTest = "
1498
 
                          "reinterpret_cast<const char *>(kTestUint64);"),
1499
 
            string::npos);
1500
 
#else
1501
 
  EXPECT_NE(os.str().find("static const char kTest[] ="), string::npos);
1502
 
#endif
1503
 
  LOG(INFO) << os.str();
 
1484
  {
 
1485
    ostringstream os;
 
1486
    const string name = "Test";
 
1487
    char buf[] = "mozc";
 
1488
    size_t buf_size = sizeof(buf);
 
1489
    Util::WriteByteArray(name, buf, buf_size, &os);
 
1490
    EXPECT_NE(os.str().find("const size_t kTest_size ="), string::npos);
 
1491
#ifdef OS_WINDOWS
 
1492
    EXPECT_NE(string::npos,
 
1493
              os.str().find("const uint64 kTest_data_uint64[] ="));
 
1494
    EXPECT_NE(string::npos,
 
1495
              os.str().find("const char *kTest_data = "
 
1496
                            "reinterpret_cast<const char *>("
 
1497
                            "kTest_data_uint64);"));
 
1498
#else
 
1499
    EXPECT_NE(os.str().find("const char kTest_data[] ="), string::npos);
 
1500
#endif
 
1501
    LOG(INFO) << os.str();
 
1502
  }
 
1503
 
 
1504
  const char kExpected[] = "const size_t ktest_size = 3;\n"
 
1505
#ifdef OS_WINDOWS
 
1506
      "const uint64 ktest_data_uint64[] = {\n"
 
1507
      "0x636261, };\n"
 
1508
      "const char *ktest_data = reinterpret_cast<const char *>("
 
1509
      "ktest_data_uint64);\n"
 
1510
#else
 
1511
      "const char ktest_data[] =\n"
 
1512
      "\"" "\\" "x61" "\\" "x62" "\\" "x63" "\"\n"
 
1513
      ";\n"
 
1514
#endif
 
1515
      ;
 
1516
  {
 
1517
    ostringstream os;
 
1518
    Util::WriteByteArray("test",
 
1519
                         "abc",
 
1520
                         3,
 
1521
                         &os);
 
1522
    EXPECT_EQ(kExpected, os.str());
 
1523
  }
 
1524
 
 
1525
  const string filepath = Util::JoinPath(FLAGS_test_tmpdir, "testfile");
 
1526
  {
 
1527
    OutputFileStream ofs(filepath.c_str());
 
1528
    ofs << "abc";
 
1529
  }
 
1530
 
 
1531
  {
 
1532
    ostringstream os;
 
1533
    Util::MakeByteArrayStream("test", filepath, &os);
 
1534
    EXPECT_EQ(kExpected, os.str());
 
1535
  }
1504
1536
}
1505
1537
 
1506
1538
TEST(UtilTest, DirectoryExists) {
1661
1693
  EXPECT_EQ(1, result.length());
1662
1694
  EXPECT_EQ("a", result);
1663
1695
}
1664
 
 
1665
1696
}  // namespace mozc