项目文件夹

文件
Chao Ma c3516f1a8e [Network] Refactoring Communicator (#679)
* Refactoring Communicator

* fix lint

* change non-const reference

* add header file

* use MemoryBuffer

* update PR

* fix bug on csr shape

* zero-copy msg_queue

* fix lint

* fix lint

* fix lint

* add header file

* fix windows build error

* fix windows build error

* update

* fix lint

* update

* fix lint

* fix lint

* add more test

* fix windows test

* update windows test

* update windows test

* update windows test

* update

* fix lint

* fix lint

* update

* update

* update

* update

* use STATUS code

* update test

* remove mem_cpy

* fix lint

* update

* finish

* ConstructNFTensor

* add test for deallocator

* update

* fix lint
2019-08-05 10:49:25 +08:00

51 行
1.4 KiB
C++

/*!
* Copyright (c) 2019 by Contributors
* \file string_test.cc
* \brief Test String Common
*/
#include <gtest/gtest.h>
#include <string>
#include <vector>
#include "../src/graph/network/common.h"
using dgl::network::SplitStringUsing;
using dgl::network::StringPrintf;
using dgl::network::SStringPrintf;
using dgl::network::StringAppendF;
TEST(SplitStringTest, SplitStringUsingCompoundDelim) {
std::string full(" apple \torange ");
std::vector<std::string> subs;
SplitStringUsing(full, " \t", &subs);
EXPECT_EQ(subs.size(), 2);
EXPECT_EQ(subs[0], std::string("apple"));
EXPECT_EQ(subs[1], std::string("orange"));
}
TEST(SplitStringTest, testSplitStringUsingSingleDelim) {
std::string full(" apple orange ");
std::vector<std::string> subs;
SplitStringUsing(full, " ", &subs);
EXPECT_EQ(subs.size(), 2);
EXPECT_EQ(subs[0], std::string("apple"));
EXPECT_EQ(subs[1], std::string("orange"));
}
TEST(SplitStringTest, testSplitingNoDelimString) {
std::string full("apple");
std::vector<std::string> subs;
SplitStringUsing(full, " ", &subs);
EXPECT_EQ(subs.size(), 1);
EXPECT_EQ(subs[0], std::string("apple"));
}
TEST(StringPrintf, normal) {
using std::string;
EXPECT_EQ(StringPrintf("%d", 1), string("1"));
string target;
SStringPrintf(&target, "%d", 1);
EXPECT_EQ(target, string("1"));
StringAppendF(&target, "%d", 2);
EXPECT_EQ(target, string("12"));
}