aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/common/options/OptionsUsageTest.java
blob: 6f3550649bbe0909f3bd500d4aae312e1758a700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
// Copyright 2017 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.common.options;

import static com.google.common.truth.Truth.assertThat;

import com.google.common.escape.Escaper;
import com.google.common.html.HtmlEscapers;
import com.google.devtools.common.options.OptionsParser.HelpVerbosity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit test for {@link OptionsUsage}. */
@RunWith(JUnit4.class)
public final class OptionsUsageTest {

  private OptionsData data;
  private static final Escaper HTML_ESCAPER = HtmlEscapers.htmlEscaper();

  @Before
  public void setUp() {
    data = OptionsParser.getOptionsDataInternal(TestOptions.class);
  }

  private String getHtmlUsageWithoutTags(String fieldName) {
    StringBuilder builder = new StringBuilder();
    OptionsUsage.getUsageHtml(
        data.getOptionDefinitionFromName(fieldName), builder, HTML_ESCAPER, data, false);
    return builder.toString();
  }

  private String getHtmlUsageWithTags(String fieldName) {
    StringBuilder builder = new StringBuilder();
    OptionsUsage.getUsageHtml(
        data.getOptionDefinitionFromName(fieldName), builder, HTML_ESCAPER, data, true);
    return builder.toString();
  }

  private String getTerminalUsageWithoutTags(String fieldName, HelpVerbosity verbosity) {
    StringBuilder builder = new StringBuilder();
    OptionsUsage.getUsage(
        data.getOptionDefinitionFromName(fieldName), builder, verbosity, data, false);
    return builder.toString();
  }

  /**
   * Tests the future behavior of the options usage output. For short & medium verbosity, this
   * should be the same as the current default
   */
  private String getTerminalUsageWithTags(String fieldName, HelpVerbosity verbosity) {
    StringBuilder builder = new StringBuilder();
    OptionsUsage.getUsage(
        data.getOptionDefinitionFromName(fieldName), builder, verbosity, data, true);
    return builder.toString();
  }

  @Test
  public void stringValue_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_string", HelpVerbosity.SHORT))
        .isEqualTo("  --test_string\n");
    assertThat(getTerminalUsageWithoutTags("test_string", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("test_string", HelpVerbosity.SHORT));
  }

  @Test
  public void stringValue_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_string", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_string (a string; default: \"test string default\")\n");
    assertThat(getTerminalUsageWithoutTags("test_string", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("test_string", HelpVerbosity.MEDIUM));
  }

  @Test
  public void stringValue_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_string", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_string (a string; default: \"test string default\")\n"
                + "    a string-valued option to test simple option operations\n");
    assertThat(getTerminalUsageWithTags("test_string", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_string (a string; default: \"test string default\")\n"
                + "    a string-valued option to test simple option operations\n"
                + "      Tags: no_op\n");
  }

  @Test
  public void stringValue_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_string"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_string\"></a>"
                + "--test_string=&lt;a string&gt</code> default: \"test string default\"</dt>\n"
                + "<dd>\n"
                + "a string-valued option to test simple option operations\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_string"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_string\"></a>"
                + "--test_string=&lt;a string&gt</code> default: \"test string default\"</dt>\n"
                + "<dd>\n"
                + "a string-valued option to test simple option operations\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void intValue_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("expanded_c", HelpVerbosity.SHORT))
        .isEqualTo("  --expanded_c\n");
    assertThat(getTerminalUsageWithoutTags("expanded_c", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("expanded_c", HelpVerbosity.SHORT));
  }

  @Test
  public void intValue_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("expanded_c", HelpVerbosity.MEDIUM))
        .isEqualTo("  --expanded_c (an integer; default: \"12\")\n");
    assertThat(getTerminalUsageWithoutTags("expanded_c", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("expanded_c", HelpVerbosity.MEDIUM));
  }

  @Test
  public void intValue_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("expanded_c", HelpVerbosity.LONG))
        .isEqualTo(
            "  --expanded_c (an integer; default: \"12\")\n"
                + "    an int-value'd flag used to test expansion logic\n");
    assertThat(getTerminalUsageWithTags("expanded_c", HelpVerbosity.LONG))
        .isEqualTo(
            "  --expanded_c (an integer; default: \"12\")\n"
                + "    an int-value'd flag used to test expansion logic\n"
                + "      Tags: no_op\n");
  }

  @Test
  public void intValue_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("expanded_c"))
        .isEqualTo(
            "<dt><code><a name=\"flag--expanded_c\"></a>"
                + "--expanded_c=&lt;an integer&gt</code> default: \"12\"</dt>\n"
                + "<dd>\n"
                + "an int-value&#39;d flag used to test expansion logic\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("expanded_c"))
        .isEqualTo(
            "<dt><code><a name=\"flag--expanded_c\"></a>"
                + "--expanded_c=&lt;an integer&gt</code> default: \"12\"</dt>\n"
                + "<dd>\n"
                + "an int-value&#39;d flag used to test expansion logic\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void booleanValue_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("expanded_a", HelpVerbosity.SHORT))
        .isEqualTo("  --[no]expanded_a\n");
    assertThat(getTerminalUsageWithoutTags("expanded_a", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("expanded_a", HelpVerbosity.SHORT));
  }

  @Test
  public void booleanValue_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("expanded_a", HelpVerbosity.MEDIUM))
        .isEqualTo("  --[no]expanded_a (a boolean; default: \"true\")\n");
    assertThat(getTerminalUsageWithoutTags("expanded_a", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("expanded_a", HelpVerbosity.MEDIUM));
  }

  @Test
  public void booleanValue_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("expanded_a", HelpVerbosity.LONG))
        .isEqualTo(
            "  --[no]expanded_a (a boolean; default: \"true\")\n"
                + "    A boolean flag with unknown effect to test tagless usage text.\n");
    // This flag has no useful tags, to verify that the tag line is omitted, so the usage line
    // should be the same in both tag and tag-free world.
    assertThat(getTerminalUsageWithoutTags("expanded_a", HelpVerbosity.LONG))
        .isEqualTo(getTerminalUsageWithTags("expanded_a", HelpVerbosity.LONG));
  }

  @Test
  public void booleanValue_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("expanded_a"))
        .isEqualTo(
            "<dt><code><a name=\"flag--expanded_a\"></a>"
                + "--[no]expanded_a</code> default: \"true\"</dt>\n"
                + "<dd>\n"
                + "A boolean flag with unknown effect to test tagless usage text.\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithoutTags("expanded_a")).isEqualTo(getHtmlUsageWithTags("expanded_a"));
  }

  @Test
  public void multipleValue_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_multiple_string", HelpVerbosity.SHORT))
        .isEqualTo("  --test_multiple_string\n");
    assertThat(getTerminalUsageWithoutTags("test_multiple_string", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("test_multiple_string", HelpVerbosity.SHORT));
  }

  @Test
  public void multipleValue_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_multiple_string", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_multiple_string (a string; may be used multiple times)\n");
    assertThat(getTerminalUsageWithoutTags("test_multiple_string", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("test_multiple_string", HelpVerbosity.MEDIUM));
  }

  @Test
  public void multipleValue_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_multiple_string", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_multiple_string (a string; may be used multiple times)\n"
                + "    a repeatable string-valued flag with its own unhelpful help text\n");
    assertThat(getTerminalUsageWithTags("test_multiple_string", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_multiple_string (a string; may be used multiple times)\n"
                + "    a repeatable string-valued flag with its own unhelpful help text\n"
                + "      Tags: no_op\n");
  }

  @Test
  public void multipleValue_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_multiple_string"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_multiple_string\"></a>"
                + "--test_multiple_string=&lt;a string&gt</code> "
                + "multiple uses are accumulated</dt>\n"
                + "<dd>\n"
                + "a repeatable string-valued flag with its own unhelpful help text\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_multiple_string"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_multiple_string\"></a>"
                + "--test_multiple_string=&lt;a string&gt</code> "
                + "multiple uses are accumulated</dt>\n"
                + "<dd>\n"
                + "a repeatable string-valued flag with its own unhelpful help text\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void customConverterValue_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_list_converters", HelpVerbosity.SHORT))
        .isEqualTo("  --test_list_converters\n");
    assertThat(getTerminalUsageWithoutTags("test_list_converters", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("test_list_converters", HelpVerbosity.SHORT));
  }

  @Test
  public void customConverterValue_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_list_converters", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_list_converters (a list of strings; may be used multiple times)\n");
    assertThat(getTerminalUsageWithoutTags("test_list_converters", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("test_list_converters", HelpVerbosity.MEDIUM));
  }

  @Test
  public void customConverterValue_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_list_converters", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_list_converters (a list of strings; may be used multiple times)\n"
                + "    a repeatable flag that accepts lists, but doesn't want to have lists of \n"
                + "    lists as a final type\n");
    assertThat(getTerminalUsageWithTags("test_list_converters", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_list_converters (a list of strings; may be used multiple times)\n"
                + "    a repeatable flag that accepts lists, but doesn't want to have lists of \n"
                + "    lists as a final type\n"
                + "      Tags: no_op\n");
  }

  @Test
  public void customConverterValue_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_list_converters"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_list_converters\"></a>"
                + "--test_list_converters=&lt;a list of strings&gt</code> "
                + "multiple uses are accumulated</dt>\n"
                + "<dd>\n"
                + "a repeatable flag that accepts lists, but doesn&#39;t want to have lists of \n"
                + "lists as a final type\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_list_converters"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_list_converters\"></a>"
                + "--test_list_converters=&lt;a list of strings&gt</code> "
                + "multiple uses are accumulated</dt>\n"
                + "<dd>\n"
                + "a repeatable flag that accepts lists, but doesn&#39;t want to have lists of \n"
                + "lists as a final type\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void staticExpansionOption_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_expansion", HelpVerbosity.SHORT))
        .isEqualTo("  --test_expansion\n");
    assertThat(getTerminalUsageWithoutTags("test_expansion", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("test_expansion", HelpVerbosity.SHORT));
  }

  @Test
  public void staticExpansionOption_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_expansion", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_expansion\n");
    assertThat(getTerminalUsageWithoutTags("test_expansion", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("test_expansion", HelpVerbosity.MEDIUM));
  }

  @Test
  public void staticExpansionOption_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_expansion", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_expansion\n"
                + "    this expands to an alphabet soup.\n"
                + "      Expands to: --noexpanded_a --expanded_b=false --expanded_c 42 --\n"
                + "      expanded_d bar \n");
    assertThat(getTerminalUsageWithTags("test_expansion", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_expansion\n"
                + "    this expands to an alphabet soup.\n"
                + "      Expands to: --noexpanded_a --expanded_b=false --expanded_c 42 --\n"
                + "      expanded_d bar \n"
                + "      Tags: no_op\n");
  }

  @Test
  public void staticExpansionOption_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_expansion"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_expansion\"></a>"
                + "--test_expansion</code></dt>\n"
                + "<dd>\n"
                + "this expands to an alphabet soup.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--noexpanded_a</code><br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_b=false</code><br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_c</code><br/>\n"
                + "&nbsp;&nbsp;<code>42</code><br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n"
                + "&nbsp;&nbsp;<code>bar</code><br/>\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_expansion"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_expansion\"></a>"
                + "--test_expansion</code></dt>\n"
                + "<dd>\n"
                + "this expands to an alphabet soup.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--noexpanded_a</code><br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_b=false</code><br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_c</code><br/>\n"
                + "&nbsp;&nbsp;<code>42</code><br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n"
                + "&nbsp;&nbsp;<code>bar</code><br/>\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void recursiveExpansionOption_shortTerminalOutput() {
    assertThat(
            getTerminalUsageWithoutTags("test_recursive_expansion_top_level", HelpVerbosity.SHORT))
        .isEqualTo("  --test_recursive_expansion_top_level\n");
    assertThat(
            getTerminalUsageWithoutTags("test_recursive_expansion_top_level", HelpVerbosity.SHORT))
        .isEqualTo(
            getTerminalUsageWithTags("test_recursive_expansion_top_level", HelpVerbosity.SHORT));
  }

  @Test
  public void recursiveExpansionOption_mediumTerminalOutput() {
    assertThat(
            getTerminalUsageWithoutTags("test_recursive_expansion_top_level", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_recursive_expansion_top_level\n");
    assertThat(
            getTerminalUsageWithoutTags("test_recursive_expansion_top_level", HelpVerbosity.MEDIUM))
        .isEqualTo(
            getTerminalUsageWithTags("test_recursive_expansion_top_level", HelpVerbosity.MEDIUM));
  }

  @Test
  public void recursiveExpansionOption_longTerminalOutput() {
    assertThat(
            getTerminalUsageWithoutTags("test_recursive_expansion_top_level", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_recursive_expansion_top_level\n"
                + "    Lets the children do all the work.\n"
                + "      Expands to: --test_recursive_expansion_middle1 --\n"
                + "      test_recursive_expansion_middle2 \n");
    assertThat(getTerminalUsageWithTags("test_recursive_expansion_top_level", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_recursive_expansion_top_level\n"
                + "    Lets the children do all the work.\n"
                + "      Expands to: --test_recursive_expansion_middle1 --\n"
                + "      test_recursive_expansion_middle2 \n"
                + "      Tags: no_op\n");
  }

  @Test
  public void recursiveExpansionOption_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_recursive_expansion_top_level"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_recursive_expansion_top_level\"></a>"
                + "--test_recursive_expansion_top_level</code></dt>\n"
                + "<dd>\n"
                + "Lets the children do all the work.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle1</code><br/>\n"
                + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle2</code><br/>\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_recursive_expansion_top_level"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_recursive_expansion_top_level\"></a>"
                + "--test_recursive_expansion_top_level</code></dt>\n"
                + "<dd>\n"
                + "Lets the children do all the work.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle1</code><br/>\n"
                + "&nbsp;&nbsp;<code>--test_recursive_expansion_middle2</code><br/>\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void expansionToMultipleValue_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_expansion_to_repeatable", HelpVerbosity.SHORT))
        .isEqualTo("  --test_expansion_to_repeatable\n");
    assertThat(getTerminalUsageWithoutTags("test_expansion_to_repeatable", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("test_expansion_to_repeatable", HelpVerbosity.SHORT));
  }

  @Test
  public void expansionToMultipleValue_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_expansion_to_repeatable", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_expansion_to_repeatable\n");
    assertThat(getTerminalUsageWithoutTags("test_expansion_to_repeatable", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("test_expansion_to_repeatable", HelpVerbosity.MEDIUM));
  }

  @Test
  public void expansionToMultipleValue_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_expansion_to_repeatable", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_expansion_to_repeatable\n"
                + "    Go forth and multiply, they said.\n"
                + "      Expands to: --test_multiple_string=expandedFirstValue --\n"
                + "      test_multiple_string=expandedSecondValue \n");
    assertThat(getTerminalUsageWithTags("test_expansion_to_repeatable", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_expansion_to_repeatable\n"
                + "    Go forth and multiply, they said.\n"
                + "      Expands to: --test_multiple_string=expandedFirstValue --\n"
                + "      test_multiple_string=expandedSecondValue \n"
                + "      Tags: no_op\n");
  }

  @Test
  public void expansionToMultipleValue_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_expansion_to_repeatable"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_expansion_to_repeatable\"></a>"
                + "--test_expansion_to_repeatable</code></dt>\n"
                + "<dd>\n"
                + "Go forth and multiply, they said.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--test_multiple_string=expandedFirstValue</code><br/>\n"
                + "&nbsp;&nbsp;<code>--test_multiple_string=expandedSecondValue</code><br/>\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_expansion_to_repeatable"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_expansion_to_repeatable\"></a>"
                + "--test_expansion_to_repeatable</code></dt>\n"
                + "<dd>\n"
                + "Go forth and multiply, they said.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--test_multiple_string=expandedFirstValue</code><br/>\n"
                + "&nbsp;&nbsp;<code>--test_multiple_string=expandedSecondValue</code><br/>\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void implicitRequirementOption_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_implicit_requirement", HelpVerbosity.SHORT))
        .isEqualTo("  --test_implicit_requirement\n");
    assertThat(getTerminalUsageWithoutTags("test_implicit_requirement", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("test_implicit_requirement", HelpVerbosity.SHORT));
  }

  @Test
  public void implicitRequirementOption_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_implicit_requirement", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_implicit_requirement (a string; default: \"direct implicit\")\n");
    assertThat(getTerminalUsageWithoutTags("test_implicit_requirement", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("test_implicit_requirement", HelpVerbosity.MEDIUM));
  }

  @Test
  public void implicitRequirementOption_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_implicit_requirement", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_implicit_requirement (a string; default: \"direct implicit\")\n"
                + "    this option really needs that other one, isolation of purpose has failed.\n"
                + "      Using this option will also add: --implicit_requirement_a=implicit \n"
                + "      requirement, required \n");
    assertThat(getTerminalUsageWithTags("test_implicit_requirement", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_implicit_requirement (a string; default: \"direct implicit\")\n"
                + "    this option really needs that other one, isolation of purpose has failed.\n"
                + "      Using this option will also add: --implicit_requirement_a=implicit \n"
                + "      requirement, required \n"
                + "      Tags: no_op\n");
  }

  @Test
  public void implicitRequirementOption_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_implicit_requirement"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_implicit_requirement\"></a>"
                + "--test_implicit_requirement=&lt;a string&gt</code> "
                + "default: \"direct implicit\"</dt>\n"
                + "<dd>\n"
                + "this option really needs that other one, isolation of purpose has failed.\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_implicit_requirement"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_implicit_requirement\"></a>"
                + "--test_implicit_requirement=&lt;a string&gt</code> "
                + "default: \"direct implicit\"</dt>\n"
                + "<dd>\n"
                + "this option really needs that other one, isolation of purpose has failed.\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void expansionFunctionOptionThatExpandsBasedOnOtherLoadedOptions_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("prefix_expansion", HelpVerbosity.SHORT))
        .isEqualTo("  --prefix_expansion\n");
    assertThat(getTerminalUsageWithoutTags("prefix_expansion", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("prefix_expansion", HelpVerbosity.SHORT));
  }

  @Test
  public void expansionFunctionOptionThatExpandsBasedOnOtherLoadedOptions_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("prefix_expansion", HelpVerbosity.MEDIUM))
        .isEqualTo("  --prefix_expansion\n");
    assertThat(getTerminalUsageWithoutTags("prefix_expansion", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("prefix_expansion", HelpVerbosity.MEDIUM));
  }

  @Test
  public void expansionFunctionOptionThatExpandsBasedOnOtherLoadedOptions_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("prefix_expansion", HelpVerbosity.LONG))
        .isEqualTo(
            "  --prefix_expansion\n"
                + "    Expands to all options with a specific prefix.\n"
                + "      Expands to: --specialexp_bar --specialexp_foo \n");
    assertThat(getTerminalUsageWithTags("prefix_expansion", HelpVerbosity.LONG))
        .isEqualTo(
            "  --prefix_expansion\n"
                + "    Expands to all options with a specific prefix.\n"
                + "      Expands to: --specialexp_bar --specialexp_foo \n"
                + "      Tags: no_op\n");
  }

  @Test
  public void expansionFunctionOptionThatExpandsBasedOnOtherLoadedOptions_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("prefix_expansion"))
        .isEqualTo(
            "<dt><code><a name=\"flag--prefix_expansion\"></a>"
                + "--prefix_expansion</code></dt>\n"
                + "<dd>\n"
                + "Expands to all options with a specific prefix.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--specialexp_bar</code><br/>\n"
                + "&nbsp;&nbsp;<code>--specialexp_foo</code><br/>\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("prefix_expansion"))
        .isEqualTo(
            "<dt><code><a name=\"flag--prefix_expansion\"></a>"
                + "--prefix_expansion</code></dt>\n"
                + "<dd>\n"
                + "Expands to all options with a specific prefix.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--specialexp_bar</code><br/>\n"
                + "&nbsp;&nbsp;<code>--specialexp_foo</code><br/>\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_NO_OP\"><code>no_op</code></a>"
                + "</dd>\n");
  }

  @Test
  public void tagHeavyExpansionOption_shortTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_void_expansion_function", HelpVerbosity.SHORT))
        .isEqualTo("  --test_void_expansion_function\n");
    assertThat(getTerminalUsageWithoutTags("test_void_expansion_function", HelpVerbosity.SHORT))
        .isEqualTo(getTerminalUsageWithTags("test_void_expansion_function", HelpVerbosity.SHORT));
  }

  @Test
  public void tagHeavyExpansionOption_mediumTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_void_expansion_function", HelpVerbosity.MEDIUM))
        .isEqualTo("  --test_void_expansion_function\n");
    assertThat(getTerminalUsageWithoutTags("test_void_expansion_function", HelpVerbosity.MEDIUM))
        .isEqualTo(getTerminalUsageWithTags("test_void_expansion_function", HelpVerbosity.MEDIUM));
  }

  @Test
  public void tagHeavyExpansionOption_longTerminalOutput() {
    assertThat(getTerminalUsageWithoutTags("test_void_expansion_function", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_void_expansion_function\n"
                + "    Listing a ton of random tags to test the usage output.\n"
                + "      Expands to: --expanded_d void expanded \n");
    assertThat(getTerminalUsageWithTags("test_void_expansion_function", HelpVerbosity.LONG))
        .isEqualTo(
            "  --test_void_expansion_function\n"
                + "    Listing a ton of random tags to test the usage output.\n"
                + "      Expands to: --expanded_d void expanded \n"
                + "      Tags: action_command_lines, test_runner, terminal_output, experimental\n");
  }

  @Test
  public void tagHeavyExpansionOption_htmlOutput() {
    assertThat(getHtmlUsageWithoutTags("test_void_expansion_function"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_void_expansion_function\"></a>"
                + "--test_void_expansion_function</code></dt>\n"
                + "<dd>\n"
                + "Listing a ton of random tags to test the usage output.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n"
                + "&nbsp;&nbsp;<code>void expanded</code><br/>\n"
                + "</dd>\n");
    assertThat(getHtmlUsageWithTags("test_void_expansion_function"))
        .isEqualTo(
            "<dt><code><a name=\"flag--test_void_expansion_function\"></a>"
                + "--test_void_expansion_function</code></dt>\n"
                + "<dd>\n"
                + "Listing a ton of random tags to test the usage output.\n"
                + "<br/>\n"
                + "Expands to:<br/>\n"
                + "&nbsp;&nbsp;<code>--expanded_d</code><br/>\n"
                + "&nbsp;&nbsp;<code>void expanded</code><br/>\n"
                + "<br>Tags: \n"
                + "<a href=\"#effect_tag_ACTION_COMMAND_LINES\"><code>action_command_lines</code>"
                + "</a>, "
                + "<a href=\"#effect_tag_TEST_RUNNER\"><code>test_runner</code></a>, "
                + "<a href=\"#effect_tag_TERMINAL_OUTPUT\"><code>terminal_output</code></a>, "
                + "<a href=\"#metadata_tag_EXPERIMENTAL\"><code>experimental</code></a>"
                + "</dd>\n");
  }
}