Statistics
| Revision:

root / trunk / tests / gtests / test_option_match.cpp @ 1577

History | View | Annotate | Download (975 Bytes)

1
#include <gtest/gtest.h>
2

    
3
class test_option_match: public ::testing::Test {};
4

    
5
TEST_F(test_option_match, calls)
6
{
7
  //ASSERT_NE(0, strcmp(0, "-option"));
8

    
9
  int option_match(int argc, char *argv[], const char *option, const int& _nopt);
10

    
11
  int nopt = -1;
12
  ASSERT_EQ(-1, option_match(0, 0, 0, nopt));
13
  ASSERT_EQ(-1, option_match(0, 0, "-check", nopt));
14

    
15
  //Should not happen, but still need to check.
16
  ASSERT_EQ(-1, option_match(1, 0, "-check", nopt));
17

    
18
  int argc = 1;
19
  char* argv[] = { "./simple"};
20

    
21
  char* option = "-none";
22
  ASSERT_EQ(-1, option_match(argc, argv, option, nopt));
23
  ASSERT_EQ(0, nopt);
24

    
25
  int argc2 = 2;
26
  char* argv2[] = { "./simple", "-myoption" };
27
  char* myoption = "-myoption";
28
  ASSERT_EQ(1, option_match(argc2, argv2, myoption, nopt));
29
  ASSERT_EQ(0, nopt);
30

    
31
  int argc3 = 3;
32
  char* argv3[] = { "./simple", "\0", "-myoption" };
33
  char* option3 = "-myoption";
34
  ASSERT_EQ(2, option_match(argc3, argv3, option3, nopt));
35
  ASSERT_EQ(0, nopt);
36
}