gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

gout_index_options_tests.c (1978B)


      1 #include "gout_index.h"
      2 
      3 #include <stdlib.h>
      4 #include <string.h>
      5 
      6 #include "utest.h"
      7 
      8 UTEST(gout_index_options, Basic) {
      9   const char* argv[] = {"gout_index", "repo1", "repo2"};
     10   GoutIndexOptions* options = gout_index_options_create(3, argv);
     11   ASSERT_NE(NULL, options);
     12   EXPECT_EQ((size_t)2, options->repo_dir_count);
     13   EXPECT_STREQ("repo1", options->repo_dirs[0]);
     14   EXPECT_STREQ("repo2", options->repo_dirs[1]);
     15   EXPECT_EQ(NULL, options->me_url);
     16   EXPECT_EQ((int)kIndexWriterTypeHtml, (int)options->writer_type);
     17   gout_index_options_free(options);
     18 }
     19 
     20 UTEST(gout_index_options, MeUrl) {
     21   const char* argv[] = {"gout_index", "-m", "https://me.com", "repo1"};
     22   GoutIndexOptions* options = gout_index_options_create(4, argv);
     23   ASSERT_NE(NULL, options);
     24   EXPECT_STREQ("https://me.com", options->me_url);
     25   EXPECT_EQ((size_t)1, options->repo_dir_count);
     26   EXPECT_STREQ("repo1", options->repo_dirs[0]);
     27   gout_index_options_free(options);
     28 }
     29 
     30 UTEST(gout_index_options, GopherWriter) {
     31   const char* argv[] = {"gout_index", "-G", "repo1"};
     32   GoutIndexOptions* options = gout_index_options_create(3, argv);
     33   ASSERT_NE(NULL, options);
     34   EXPECT_EQ((int)kIndexWriterTypeGopher, (int)options->writer_type);
     35   gout_index_options_free(options);
     36 }
     37 
     38 UTEST(gout_index_options, HtmlWriter) {
     39   const char* argv[] = {"gout_index", "-H", "repo1"};
     40   GoutIndexOptions* options = gout_index_options_create(3, argv);
     41   ASSERT_NE(NULL, options);
     42   EXPECT_EQ((int)kIndexWriterTypeHtml, (int)options->writer_type);
     43   gout_index_options_free(options);
     44 }
     45 
     46 UTEST(gout_index_options, Empty) {
     47   const char* argv[] = {"gout_index"};
     48   GoutIndexOptions* options = gout_index_options_create(1, argv);
     49   ASSERT_NE(NULL, options);
     50   EXPECT_EQ((size_t)0, options->repo_dir_count);
     51   gout_index_options_free(options);
     52 }
     53 
     54 UTEST(gout_index_options, MissingMeUrl) {
     55   const char* argv[] = {"gout_index", "-m"};
     56   GoutIndexOptions* options = gout_index_options_create(2, argv);
     57   EXPECT_EQ(NULL, options);
     58 }