Ejemplo n.º 1
0
/**
 * Basic test for reallocation
 */
void test_Brealloc(void)
{
    UBFH *p_ub = NULL;

    p_ub=Balloc(1, 30);
    assert_not_equal(p_ub, NULL);

    assert_equal(Badd(p_ub, T_STRING_FLD, BIG_TEST_STRING, 0), FAIL);
    assert_equal(Berror, BNOSPACE);

    /* Now reallocate, space should be bigger! */
    p_ub=Brealloc(p_ub, 1, strlen(BIG_TEST_STRING)+1+2/* align */);
    assert_not_equal(p_ub, NULL);
    assert_equal(Badd(p_ub, T_STRING_FLD, BIG_TEST_STRING, 0), SUCCEED);
    
    /* should not allow to reallocate to 0! */
    assert_equal(Brealloc(p_ub, 1, 0), NULL);
    assert_equal(Berror, BEINVAL);

    /* should be bigger than existing. */
    assert_equal(Brealloc(p_ub, 1, strlen(BIG_TEST_STRING)+1), NULL);
    assert_equal(Berror, BEINVAL);

    assert_equal(SUCCEED, Bfree(p_ub));

}
Ejemplo n.º 2
0
TEST(not equal) {
  assert_not_equal(2,   17 - 16,   SHOULD(match integers));
  assert_not_equal(2U,  17U - 16U, SHOULD(match unsigned integers));
  assert_not_equal(1.0, 2.0,       SHOULD(match floats));

  std::string x = "One";
  std::string y = "Two";
  assert_not_equal(x, y,           SHOULD(match strings));
}
Ejemplo n.º 3
0
void test_5() {
  vvi adj(5);

  pair<union_find, vi> res = scc(adj);
  union_find scc = res.first;

  assert_not_equal(scc.find(0), scc.find(1));
  assert_not_equal(scc.find(0), scc.find(2));
  assert_not_equal(scc.find(0), scc.find(3));
  assert_not_equal(scc.find(0), scc.find(4));
  assert_not_equal(scc.find(1), scc.find(2));
  assert_not_equal(scc.find(1), scc.find(3));
  assert_not_equal(scc.find(1), scc.find(4));
  assert_not_equal(scc.find(2), scc.find(3));
  assert_not_equal(scc.find(2), scc.find(4));
  assert_not_equal(scc.find(3), scc.find(4));
}
Ejemplo n.º 4
0
void test_2() {
  vvi adj(2);

  adj[0].push_back(1);

  pair<union_find, vi> res = scc(adj);
  union_find scc = res.first;

  assert_not_equal(scc.find(0), scc.find(1));
}
Ejemplo n.º 5
0
void func_real()
{
    istat::DisableStderr dl;
    mkdir("/tmp/test/config", 511);
    int i = open("/tmp/test/config/precreate.set", O_RDWR | O_CREAT, 511);
    assert_not_equal(i, -1);
    close(i);
    i = open("/tmp/test/config/set.set", O_RDWR | O_CREAT, 511);
    char const *str = "# istatd settings 1\nname=value\nname2=value2\n";
    assert_not_equal(i, -1);
    assert_equal(write(i, str, strlen(str)), (ssize_t)strlen(str));
    close(i);
    ISettingsFactory *isf = NewSettingsFactory(svc, "/tmp/test/config");
    test_SettingsFactory(isf);
    isf->dispose();

    //  make sure the file exists
    struct stat stbuf;
    assert_equal(0, stat("/tmp/test/config/allowCreate.set", &stbuf));
}
Ejemplo n.º 6
0
void test_4() {
  vvi adj(5);

  adj[0].push_back(1);
  adj[1].push_back(2);
  adj[2].push_back(3);
  adj[3].push_back(4);

  pair<union_find, vi> res = scc(adj);
  union_find scc = res.first;

  assert_not_equal(scc.find(0), scc.find(1));
  assert_not_equal(scc.find(0), scc.find(2));
  assert_not_equal(scc.find(0), scc.find(3));
  assert_not_equal(scc.find(0), scc.find(4));
  assert_not_equal(scc.find(1), scc.find(2));
  assert_not_equal(scc.find(1), scc.find(3));
  assert_not_equal(scc.find(1), scc.find(4));
  assert_not_equal(scc.find(2), scc.find(3));
  assert_not_equal(scc.find(2), scc.find(4));
  assert_not_equal(scc.find(3), scc.find(4));
}
Ejemplo n.º 7
0
void test_6() {
  vvi adj(2);

  for (int i = 0; i < 100; i++)
  {
    adj[0].push_back(0);
    adj[1].push_back(1);
  }

  pair<union_find, vi> res = scc(adj);
  union_find scc = res.first;

  assert_not_equal(scc.find(0), scc.find(1));
}
Ejemplo n.º 8
0
/**
 * Test Balloc
 * @return
 */
void test_Balloc_Bfree(void)
{
    UBFH *p_ub = NULL;
    int i;
    /* will check with valgrind - do we have memory leaks or not */
    
    for (i=0; i<20; i++)
    {
        p_ub=Balloc(20, 30);
        assert_not_equal(p_ub, NULL);
        /* Put some data into memory so that we can test */
        set_up_dummy_data(p_ub);
        do_dummy_data_test(p_ub);
        assert_equal(Bfree(p_ub), SUCCEED);

    }
}
Ejemplo n.º 9
0
void test_10() {
  vvi adj(4);

  adj[0].push_back(1);
  adj[1].push_back(0);
  adj[2].push_back(1);
  adj[2].push_back(3);
  adj[3].push_back(2);

  pair<union_find, vi> res = scc(adj);
  union_find scc = res.first;
  vi dag = res.second;

  assert_equal(scc.find(0), scc.find(1));
  assert_equal(scc.find(2), scc.find(3));
  assert_not_equal(scc.find(0), scc.find(2));

  assert_equal(scc.find(0), scc.find(dag[0]));
  assert_equal(scc.find(2), scc.find(dag[1]));
}
Ejemplo n.º 10
0
Ensure zero_should_assert_short_not_equal_to_one() {
	short x = 0;
	short y = 1;
    assert_not_equal(x, y);
}
Ejemplo n.º 11
0
void test_SettingsFactory(ISettingsFactory *fsf)
{
    //  can I open an existing entry?
    boost::shared_ptr<ISettings> set;
    fsf->open("set", false, set, comp);
    pump_and_run();
    assert_not_equal(set.get(), (ISettings *)0);

    //  Can I get a setting that exists?
    std::string oValue;
    bool wasSet = false;
    set->get("name", oValue, wasSet, "");
    assert_true(wasSet);
    assert_equal(oValue, "value");

    //  Can I get the default for a setting that doesn't exist?
    oValue = "";
    wasSet = false;
    set->get("name3", oValue, wasSet, "dflt");
    assert_false(wasSet);
    assert_equal(oValue, "dflt");

    //  can I iterate keys?
    std::vector<std::string> oKeys;
    set->match("name*", oKeys);
    assert_equal(oKeys.size(), 2);
    //  I know the keys come out sorted
    assert_equal(oKeys[0], "name");
    assert_equal(oKeys[1], "name2");

    //  Do I get denied creating a setting that's not pre-created?
    //  (also, this is a bad filename for the real version)
    fsf->open("none/such", true, set, comp);
    pump_and_run();
    assert_equal(set.get(), (ISettings *)0);

    //  Do I get denied not creating something that's allowed to be created?
    fsf->open("allowCreate", false, set, comp);
    pump_and_run();
    assert_equal(set.get(), (ISettings *)0);

    //  Can I create something I'm allowed to create?
    fsf->open("allowCreate", true, set, comp);
    pump_and_run();
    assert_not_equal(set.get(), (ISettings *)0);

    //  Can I set keys and then find them?
    set->set("kk", "vv");
    set->set("qq", "pewpew");
    oValue = "";
    wasSet = false;
    set->get("kk", oValue, wasSet, "");
    assert_equal(oValue, "vv");
    assert_true(wasSet);
    oValue = "";
    wasSet = false;
    set->get("qq", oValue, wasSet, "");
    assert_equal(oValue, "pewpew");
    assert_true(wasSet);
    oValue = "";
    wasSet = false;
    set->get("zz", oValue, wasSet, "");
    assert_equal(oValue, "");
    assert_false(wasSet);
    oKeys.clear();
    set->match("q*", oKeys);
    assert_equal(oKeys.size(), 1);
    assert_equal(oKeys[0], "qq");

    fsf->flush(comp);
    pump_and_run();
}
Ejemplo n.º 12
0
Ensure zero_should_assert_unsigned_char_not_equal_to_one() {
	unsigned char x = 0;
	unsigned char y = 1;
    assert_not_equal(x, y);
}
Ejemplo n.º 13
0
Ensure zero_should_assert_not_equal_to_one() {
    assert_not_equal(0, 1);
}
Ejemplo n.º 14
0
Ensure zero_should_assert_long_long_not_equal_to_one() {
	long long x = 0;
	long long y = 1;
    assert_not_equal(x, y);
}
Ejemplo n.º 15
0
Ensure zero_should_assert_char_not_equal_to_one() {
	char x = 0;
	char y = 1;
    assert_not_equal(x, y);
}
Ejemplo n.º 16
0
Ensure zero_should_assert_unsigned_short_not_equal_to_one() {
	unsigned short x = 0;
	unsigned short y = 1;
    assert_not_equal(x, y);
}
Ejemplo n.º 17
0
Ensure zero_should_assert_unsigned_long_long_not_equal_to_one() {
	unsigned long long x = 0;
	unsigned long long y = 1;
    assert_not_equal(x, y);
}