当前位置: 首页>>代码示例>>C++>>正文


C++ ASSERT_NE函数代码示例

本文整理汇总了C++中ASSERT_NE函数的典型用法代码示例。如果您正苦于以下问题:C++ ASSERT_NE函数的具体用法?C++ ASSERT_NE怎么用?C++ ASSERT_NE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ASSERT_NE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BOOST_FIXTURE_TEST_CASE

BOOST_FIXTURE_TEST_CASE(readFilePath, JsonFilePaserTestInit){
  std::string filename;
  TEST_ASSERT(jsonFile.readFilePath("filename",filename,false));
  ASSERT_NE(filename,std::string("f.txt"));
  ASSERT_EQ(filename,jsonFile.getFileDir()+std::string("f.txt"));
}
开发者ID:Tonsty,项目名称:Utility,代码行数:6,代码来源:JsonFilePaserTest.cpp

示例2: TEST

TEST(sys_mman, mremap_PTRDIFF_MAX) {
  void* map = mmap(nullptr, PAGE_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  ASSERT_NE(MAP_FAILED, map);
  ASSERT_EQ(MAP_FAILED, mremap(map, PAGE_SIZE, kHuge, MREMAP_MAYMOVE));
}
开发者ID:multi-os-engine,项目名称:platform_bionic,代码行数:5,代码来源:sys_mman_test.cpp

示例3: TEST

TEST(SocketTests, ClientServer) {
    int fd_socket, fd_connect;
    int port, res;
    pid_t child;
    socklen_t size;
    struct sockaddr_in saddr = {};
    char buf[512];

    saddr.sin_family = AF_INET;
    saddr.sin_addr.s_addr = INADDR_ANY;
    /* use 0 so the kernel assigns us an open port # */
    saddr.sin_port = htons(0);

    fd_socket = socket(AF_INET, SOCK_STREAM, 0);
    ASSERT_NE(fd_socket, -1);
    res = bind(fd_socket, (struct sockaddr *) &saddr, sizeof(saddr));
    ASSERT_NE(res, -1);
    res = listen(fd_socket, 16/*max queue length*/);
    ASSERT_NE(res, -1);

    /* get the port # we were assigned */
    size = sizeof(saddr);
    res = getsockname(fd_socket, (struct sockaddr *) &saddr, &size);
    ASSERT_NE(res, -1);
    port = ntohs(saddr.sin_port);

    child = fork();
    ASSERT_TRUE(child >= 0);
    if (child == 0) {
        struct sockaddr from_addr;
        socklen_t from_len = sizeof(from_addr);
        int fd_client;
        struct hostent *hp = gethostbyname("localhost");
        ASSERT_NE(hp, (struct hostent *)NULL);

        memset(&saddr, 0, sizeof(saddr));
        saddr.sin_family = AF_INET;
        saddr.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
        saddr.sin_port = htons(port);

        /* connect and exchange greetings */
        fd_client = socket(AF_INET, SOCK_STREAM, 0);
        ASSERT_NE(fd_client, -1);
        res = connect(fd_client, (struct sockaddr *) &saddr, sizeof(saddr));
        ASSERT_NE(res, -1);
        res = send(fd_client, "hello", strlen("hello")+1, 0);
        ASSERT_NE(res, -1);
        res = recvfrom(fd_client, buf, sizeof(buf), 0, &from_addr, &from_len);
        ASSERT_NE(res, -1);
        EXPECT_EQ(0, (int)from_len);  /* no from addr with SOCK_STREAM */
        ASSERT_STREQ(buf, "goodbye");

        close(fd_client);
        exit(0);
    } else {
        /* wait for child to connect */
        size = sizeof(saddr); 
        fd_connect = accept(fd_socket, (struct sockaddr *) &saddr, &size);
        ASSERT_NE(fd_connect, -1);

        /* exchange greetings */
        res = recv(fd_connect, buf, sizeof(buf), 0);
        ASSERT_NE(res, -1);
        ASSERT_STREQ(buf, "hello");
        res = send(fd_connect, "goodbye", strlen("goodbye")+1, 0);
        ASSERT_NE(res, -1);

        int status;
        do {
            res = waitpid(child, &status, 0);
        } while (res == -1 && errno == EINTR);
        ASSERT_EQ(res, child);
        ASSERT_EQ(0, status);

        close(fd_connect);
        close(fd_socket);
    }
}
开发者ID:rnk,项目名称:drmemory,代码行数:78,代码来源:socket_tests_posix.cpp

示例4: TEST

TEST(stat_test, get_config) {
    stat_client cli(host(), port(), cluster_name(), timeout());
    ASSERT_NE("", cli.get_config());
}
开发者ID:josephwinston,项目名称:jubatus,代码行数:4,代码来源:stat_test.cpp

示例5: locate_file

char *
locate_file (const char *name)
{
  ASSERT_NE (NULL, path_to_selftest_files);
  return concat (path_to_selftest_files, "/", name, NULL);
}
开发者ID:WojciechMigda,项目名称:gcc,代码行数:6,代码来源:selftest.c

示例6: TEST_F

TEST_F(ExoticaTaskTest, XIT) //!< XML Initialisation Test
{
    boost::shared_ptr<tinyxml2::XMLHandle> xml_handle;
    tinyxml2::XMLDocument doc;
    ASSERT_EQ(tinyxml2::XML_NO_ERROR,
              doc.LoadFile((resource_path_ + std::string("ex_task_1.xml")).c_str()));
    xml_handle.reset(new tinyxml2::XMLHandle(*(doc.RootElement())));
    ASSERT_NE(nullptr, xml_handle)<< " : Aborting: could  not initialise";

    params_.optimisation_window = 2;  //!< Test with 2 instances
    task1_p_ = boost::dynamic_pointer_cast<ExoticaTaskTest_1>(
                   exotica::TaskCreator::Instance()->createObject("ExoticaTask_1", params_));
    ASSERT_TRUE(task1_p_ != nullptr)<<" : Could not initialise object";
    EXPECT_EQ(2, task1_p_->getParameters().optimisation_window)
            << " : Incorrect initialisation";
    EXPECT_TRUE(task1_p_->initBase(*xml_handle));
    EXPECT_TRUE(task1_p_->derived_called);
    task1_p_->clearFlags();

    //!< Goal Weights
    EXPECT_EQ(Eigen::MatrixXd::Identity(3, 3), task1_p_->getGoalWeights(0));
    EXPECT_EQ(Eigen::MatrixXd::Ones(3, 3), task1_p_->getGoalWeights(1));
    EXPECT_EQ(Eigen::MatrixXd::Zero(1, 1), task1_p_->getGoalWeights(2));

    //!< Task Weight
    EXPECT_FLOAT_EQ(0.5, task1_p_->getTaskWeight(0));
    EXPECT_FLOAT_EQ(0.2, task1_p_->getTaskWeight(1));
    EXPECT_GT(0, task1_p_->getTaskWeight(2));

    //!< Goal
    Eigen::VectorXd goal_0(3);
    Eigen::VectorXd goal_1(3);
    goal_0 << 0.2, 0.4, 0.6;
    goal_1 << 0.5, 0.5, 0.5;
    ASSERT_EQ(goal_0.size(), task1_p_->getGoal(0).size());
    EXPECT_EQ(goal_0, task1_p_->getGoal(0));
    EXPECT_FLOAT_EQ(0.2, task1_p_->getTolerance()); //!< Should give the zeroth one..
    ASSERT_EQ(goal_1.size(), task1_p_->getGoal(1).size());
    EXPECT_EQ(goal_1, task1_p_->getGoal(1));
    EXPECT_FLOAT_EQ(0.01, task1_p_->getTolerance(1));
    EXPECT_EQ(Eigen::VectorXd::Zero(1), task1_p_->getGoal(2));
    EXPECT_GT(0, task1_p_->getTolerance(2));

    //!< Private members (check that they are passed ok from base) (task of type 2)
    ASSERT_EQ(tinyxml2::XML_NO_ERROR,
              doc.LoadFile(
                  (resource_path_ + std::string("ExoticaTask2_default.xml")).c_str()));
    xml_handle.reset(new tinyxml2::XMLHandle(*(doc.RootElement())));
    ASSERT_NE(nullptr, xml_handle)<< " : Aborting: could  not initialise";

    params_.optimisation_window = 1;  //!< Test with 1 instances
    task2_p_ = boost::dynamic_pointer_cast<ExoticaTaskTest_2>(
                   exotica::TaskCreator::Instance()->createObject("ExoticaTask_2", params_));
    ASSERT_TRUE(task2_p_ != nullptr)<<" : Could not initialise object";
    EXPECT_EQ(1, task2_p_->getParameters().optimisation_window)
            << " : Incorrect initialisation";
    EXPECT_TRUE(task2_p_->initBase(*xml_handle));
    EXPECT_TRUE(task2_p_->derived_called);
    task2_p_->clearFlags();
    EXPECT_EQ(6, task2_p_->int_element);
    EXPECT_EQ(0, task2_p_->string_element.compare("blabla"));
}
开发者ID:bmagyar,项目名称:exotica,代码行数:62,代码来源:TaskDefinitionTest.cpp

示例7: segment_length

 /** 
  * Return the number of rows in the segment.
  * Will throw an exception if the sarray is invalid (there is an error
  * reading files)
  */
 size_t segment_length(size_t segment) const {
   ASSERT_NE(reader, NULL);
   return m_segment_lengths[segment];
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:9,代码来源:sarray_reader.hpp

示例8: get_index_file

 /**
  * Return the file prefix of the sarray (paramter on construction)
  */
 std::string get_index_file() const {
   ASSERT_NE(reader, NULL);
   return reader->get_index_file();
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:7,代码来源:sarray_reader.hpp

示例9: TEST

TEST(SlotMap, ReplaceNodesAlsoSlave)
{
    cerb::SlotMap::select_slave_if_possible();
    cerb::SlotMap slot_map;

    std::set<cerb::Server*> replaced = slot_map.replace_map(cerb::parse_slot_map(
                                           "69853562969c74ff387f9e491d025b2a86ac478f 192.168.1.100:7002 master - 0 0 3 connected 8192-12287\n"
                                           "2f53d0fb4a59274e83e47b1dca02697384822ca5 192.168.1.100:7006 slave 69853562969c74ff387f9e491d025b2a86ac478f 0 0 3 connected\n"
                                           "2560c867f9ca2ef4cc872eb85ce985373ad9e815 192.168.1.101:7003 master - 0 0 2 connected 0-4095\n"
                                           "933970b4fd2d1ad06166ab1d893e8cac7b129ebd 192.168.1.101:7001 master - 0 0 4 connected 4096-8191\n"
                                           "d3adf40539ad749d214609987563bf9903a57ffc 192.168.1.101:7007 slave 2560c867f9ca2ef4cc872eb85ce985373ad9e815 0 0 2 connected\n"
                                           "6c001456aff0ae537ba242d4e86fb325c5babbea 192.168.1.100:7000 myself,master - 0 0 1 connected 12288-16383\n",
                                           "127.0.0.1"), nullptr);

    ASSERT_TRUE(replaced.empty());

    for (cerb::slot s = 0; s < 4096; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.101", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7007, svr->addr.port) << " slot #" << s;
    }

    for (cerb::slot s = 4096; s < 8192; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.101", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7001, svr->addr.port) << " slot #" << s;
    }

    for (cerb::slot s = 8192; s < 12288; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.100", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7006, svr->addr.port) << " slot #" << s;
    }

    for (cerb::slot s = 12288; s < 16384; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.100", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7000, svr->addr.port) << " slot #" << s;
    }

    std::set<cerb::Server*> to_be_replaced;
    to_be_replaced.insert(slot_map.get_by_slot(0));

    replaced = slot_map.replace_map(cerb::parse_slot_map(
                                        "69853562969c74ff387f9e491d025b2a86ac478f 192.168.1.100:7002 master - 0 0 3 connected 8192-12287\n"
                                        "2f53d0fb4a59274e83e47b1dca02697384822ca5 192.168.1.100:7006 slave 69853562969c74ff387f9e491d025b2a86ac478f 0 0 3 connected\n"
                                        "2560c867f9ca2ef4cc872eb85ce985373ad9e815 192.168.1.101:7003 master - 0 0 2 connected 0-4095\n"
                                        "933970b4fd2d1ad06166ab1d893e8cac7b129ebd 192.168.1.101:7001 master - 0 0 4 connected 4096-8191\n"
                                        "6c001456aff0ae537ba242d4e86fb325c5babbea 192.168.1.100:7000 myself,master - 0 0 1 connected 12288-16383\n",
                                        "127.0.0.1"), nullptr);

    ASSERT_EQ(to_be_replaced, replaced);

    for (cerb::slot s = 0; s < 4096; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.101", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7003, svr->addr.port) << " slot #" << s;
    }

    for (cerb::slot s = 4096; s < 8192; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.101", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7001, svr->addr.port) << " slot #" << s;
    }

    for (cerb::slot s = 8192; s < 12288; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.100", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7006, svr->addr.port) << " slot #" << s;
    }

    for (cerb::slot s = 12288; s < 16384; ++s) {
        cerb::Server* svr = slot_map.get_by_slot(s);
        ASSERT_NE(nullptr, svr) << " slot #" << s;
        ASSERT_EQ("192.168.1.100", svr->addr.host) << " slot #" << s;
        ASSERT_EQ(7000, svr->addr.port) << " slot #" << s;
    }
}
开发者ID:nevermatch,项目名称:redis-cerberus,代码行数:85,代码来源:slot_map.cpp

示例10: num_segments

 /** 
  * Return the number of segments in the collection. 
  * Will throw an exception if the sarray is invalid (there is an error
  * reading files)
  */
 size_t num_segments() const {
   ASSERT_NE(reader, NULL);
   return m_num_segments;
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:9,代码来源:sarray_reader.hpp

示例11: TEST_F

TEST_F(HostTest, IsSingleton) {

	ASSERT_NE(h, NULL);
	ASSERT_NE(*h, NULL);

}
开发者ID:jmriviere,项目名称:pbrt-v2,代码行数:6,代码来源:test_host.cpp

示例12: TEST

TEST(MallocTests, HeapCompact) {
    HANDLE heap = GetProcessHeap();
    ASSERT_NE(heap, (HANDLE)NULL);
    SIZE_T largest = HeapCompact(heap, 0);
    ASSERT_GT(largest, 1024);
}
开发者ID:Maximus5,项目名称:drmemory,代码行数:6,代码来源:malloc_tests_win.cpp

示例13: TEST

// Checks the tests are running against ANGLE
TEST(EGLSanityCheckTest, IsRunningOnANGLE)
{
    const char *extensionString =
        static_cast<const char *>(eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS));
    ASSERT_NE(strstr(extensionString, "EGL_ANGLE_platform_angle"), nullptr);
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:7,代码来源:EGLSanityCheckTest.cpp

示例14: get_file_names

 /**
  * Returns the collection of files storing the sarray.
  * For instance: [file_prefix].sidx, [file_prefix].0001, etc.
  */
 std::vector<std::string> get_file_names() const {
   ASSERT_NE(reader, NULL);
   return reader->get_index_info().segment_files;
 }
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:8,代码来源:sarray_reader.hpp

示例15: main

int main(int argc, char** argv) {
//   cppipc::comm_client client({"localhost:2181"}, "test");
  cppipc::comm_client client({}, "tcp://127.0.0.1:19000");
  /*
  cppipc::comm_client client({}, 
                             "ipc:///tmp/cppipc_server_test");
                             */
  if (argc >= 2) {
    client.add_auth_method(std::make_shared<cppipc::authentication_token_method>(argv[1]));
  }
  client.start();
  client.add_status_watch(WATCH_COMM_SERVER_INFO, 
                          [](std::string message) {
                          std::cout << message << "\n";
                          });

  for (size_t i = 0;i < 100; ++i) {
  try { 
    test_object_proxy test_object(client);
    std::cout << test_object.ping("hello world") << "\n";

    std::cout << "5 + 1 = " << test_object.add_one(5, "hello") << "\n";
    std::cout << "5 + 5 = " << test_object.add(5, 5) << "\n";
    std::cout << "5 - 5 = " << test_object.subtract(5, 5) << "\n";
    std::cout << "return_one = " << test_object.return_one() << "\n";
    ASSERT_EQ(test_object.add(5, 5), 10);
    ASSERT_EQ(test_object.subtract(5, 5), 0);
  } catch (cppipc::reply_status status) {
    std::cout << "Exception: " << cppipc::reply_status_to_string(status) << "\n";
  } catch (const char* s) {
    std::cout << "Exception: " << s << "\n";
  }
  }

  std::shared_ptr<test_object_proxy> pika(std::make_shared<test_object_proxy>(client));
  std::shared_ptr<test_object_proxy> chu(std::make_shared<test_object_proxy>(client));

  pika->set_value(10);
  chu->set_value(5);
  ASSERT_EQ(pika->get_value(), 10);
  ASSERT_EQ(chu->get_value(), 5);

  pika->subtract_from(std::static_pointer_cast<test_object_base>(chu));
  ASSERT_EQ(pika->get_value(), 5);
  ASSERT_EQ(chu->get_value(), 5);

  chu->subtract_from(std::static_pointer_cast<test_object_base>(pika));
  ASSERT_EQ(pika->get_value(), 5);
  ASSERT_EQ(chu->get_value(), 0);

  pika->swap(std::static_pointer_cast<test_object_base>(chu));
  ASSERT_EQ(pika->get_value(), 0);
  ASSERT_EQ(chu->get_value(), 5);

  chu->swap(std::static_pointer_cast<test_object_base>(pika));
  ASSERT_EQ(pika->get_value(), 5);
  ASSERT_EQ(chu->get_value(), 0);

  chu->set_value(2);
  std::shared_ptr<test_object_proxy> p = std::dynamic_pointer_cast<test_object_proxy>(*pika - chu);
  ASSERT_NE(p.get(), NULL);
  ASSERT_EQ(p->get_value(), 3);

  // Test objects with reference count greater than 1
  std::shared_ptr<test_object_proxy> q = std::dynamic_pointer_cast<test_object_proxy>(*pika + chu);
  ASSERT_EQ(q->get_value(), 7);
  ASSERT_EQ(chu->get_value(), 7);
  ASSERT_EQ(pika->get_value(), 5);

  bool exception_caught = false;
  try {
    chu->an_exception();
  } catch (cppipc::ipcexception& except) {
    std::cout << except.what() << "\n";
    exception_caught = true;
  }

  ASSERT_TRUE(exception_caught);

  // ping test with increasing lengths
  test_object_proxy test_object(client);
  for (size_t i = 0;i <= 25; ++i) {
    size_t j = ((size_t)1 << i) - 1;
    graphlab::timer ti;
    std::cout << "Sending ping of length " << j << std::endl;
    std::string ret = test_object.return_big_object(j);
    std::cout << "Ping of length " << j << " RTT = " << ti.current_time() << "s" << std::endl;
    ASSERT_EQ(ret.length(), j);
  }
  p.reset();
}
开发者ID:Bhushan1002,项目名称:SFrame,代码行数:91,代码来源:client_test.cpp


注:本文中的ASSERT_NE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。