Skip to content

Commit

Permalink
test_getopt_longの不具合を修正
Browse files Browse the repository at this point in the history
コマンドラインを正しく分割できていなかった。
  • Loading branch information
takamin committed Oct 16, 2015
1 parent 215a7f9 commit 49a6c6c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/test_getopt_long.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,17 @@
#include <vector>
#include <stdio.h>
#include <stdlib.h>

#if defined(_MSC_VER)

#include "getopt.h"

#elif defined(_GCC)

#include <getopt.h>

#endif

using namespace std;

class Arg {
Expand Down Expand Up @@ -103,9 +112,15 @@ int Arg::split(char const* in, vector<string>& argv)
inword = false;
argv.push_back(ss.str());
ss.str("");
argc++;
}
}
}
if(ss.str() != "") {
argv.push_back(ss.str());
ss.str("");
argc++;
}
return argc;
}
static void test_equal(char const* name, int A, int B, bool condition) {
Expand All @@ -128,7 +143,7 @@ int main(int argc, char* argv[]) {
};
int longindex = 0;
int opt = 0;
Arg test01arg("a.out --aaa --bbb --ccc");
Arg test01arg("a.out --aa --bbb --c");
opt = getopt_long(test01arg.count(), test01arg.values(), "abc", opt01, &longindex);
TEST_EQUAL(opt, 'a');
TEST_EQUAL(longindex, 0);
Expand Down

0 comments on commit 49a6c6c

Please sign in to comment.