Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <gtest/gtest.h>
00037 #include "ros/names.h"
00038
00039 using namespace ros;
00040
00041 TEST(Names, validation)
00042 {
00043 std::string error;
00044 EXPECT_TRUE(names::validate("", error));
00045 EXPECT_TRUE(names::validate("hello", error));
00046 EXPECT_TRUE(names::validate("/hello/asdf", error));
00047 EXPECT_TRUE(names::validate("hello/fdas", error));
00048 EXPECT_TRUE(names::validate("/hello", error));
00049 EXPECT_TRUE(names::validate("~hello", error));
00050 EXPECT_TRUE(names::validate("/hello_world/blah_world", error));
00051 EXPECT_TRUE(names::validate("hello123_421", error));
00052 EXPECT_FALSE(names::validate("123hello", error));
00053 EXPECT_FALSE(names::validate("_hello", error));
00054 EXPECT_FALSE(names::validate("h~ello", error));
00055 EXPECT_FALSE(names::validate("%hello", error));
00056 EXPECT_FALSE(names::validate("h ello", error));
00057 EXPECT_FALSE(names::validate("h*ello", error));
00058 EXPECT_FALSE(names::validate("h?ello", error));
00059 }
00060
00061 TEST(Names, parentNamespace)
00062 {
00063
00064 EXPECT_STREQ(std::string("").c_str(), names::parentNamespace("").c_str());
00065 EXPECT_STREQ(std::string("/").c_str(), names::parentNamespace("/").c_str());
00066 EXPECT_STREQ(std::string("/").c_str(), names::parentNamespace("/a").c_str());
00067 EXPECT_STREQ(std::string("/").c_str(), names::parentNamespace("/a/").c_str());
00068
00069
00070 EXPECT_STREQ(std::string("/a").c_str(), names::parentNamespace("/a/b").c_str());
00071 EXPECT_STREQ(std::string("/a").c_str(), names::parentNamespace("/a/b/").c_str());
00072 EXPECT_STREQ(std::string("/asdf").c_str(), names::parentNamespace("/asdf/b").c_str());
00073
00074
00075 EXPECT_STREQ(std::string("/z/a").c_str(), names::parentNamespace("/z/a/b").c_str());
00076 EXPECT_STREQ(std::string("/z/a").c_str(), names::parentNamespace("/z/a/b/").c_str());
00077 EXPECT_STREQ(std::string("/z/asdf").c_str(), names::parentNamespace("/z/asdf/b").c_str());
00078 }
00079
00080 int
00081 main(int argc, char** argv)
00082 {
00083 testing::InitGoogleTest(&argc, argv);
00084 return RUN_ALL_TESTS();
00085 }
00086
00087