/** Ċ Ġ* ĠTests Ġfor ĠMain Ġclass . Ċ Ġ* Ċ Ġ* ĠCreated Ġby Ġmi qu if ant Ġon Ġ 2 0 2 0 - 1 0 - 1 8 Ċ Ġ*/ Ċ package Ġmi qu if ant . get em all Ċ Ċ import Ġmi qu if ant . get em all . utils . simple Split Ċ Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . contrib . java . lang . system . Expected System Exit Ċ Ċ import Ġkotlin . test .* ĊĊ Ċ class ĠTest Main Ġ{ ĊĊĠ Ġ@ get : Rule ĊĠ Ġval Ġexit : ĠExpected System Exit Ġ= ĠExpected System Exit . none () ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts Un existing Command () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" un existing " ĊĠĠĠ Ġexit . expect System Exit With Status ( 1 ) ĊĠĠĠ Ġparse Opts ( args . simple Split ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts No Command No Opts () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ"" ĊĠĠĠ Ġexit . expect System Exit With Status ( 1 ) ĊĠĠĠ Ġparse Opts ( args . simple Split ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts No Command Wrong Opts () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ"-- un existing - option " ĊĠĠĠ Ġexit . expect System Exit With Status ( 1 ) ĊĠĠĠ Ġparse Opts ( args . simple Split ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts No Command Ok () Ġ{ ĊĠĠĠ Ġval Ġargs Help 1 Ġ= Ġ"- h " ĊĠĠĠ Ġval Ġopts Help 1 Ġ= Ġparse Opts ( args Help 1 . simple Split ()) ĊĠĠĠ ĠassertTrue ( opts Help 1 [" -- help "] Ġas ĠBoolean ) ĊĊĠĠĠ Ġval Ġargs Help 2 Ġ= Ġ"-- help " ĊĠĠĠ Ġval Ġopts Help 2 Ġ= Ġparse Opts ( args Help 2 . simple Split ()) ĊĠĠĠ ĠassertTrue ( opts Help 2 [" -- help "] Ġas ĠBoolean ) ĊĊĠĠĠ Ġval Ġargs Version Ġ= Ġ"-- version " ĊĠĠĠ Ġval Ġopts Version Ġ= Ġparse Opts ( args Version . simple Split ()) ĊĠĠĠ ĠassertTrue ( opts Version [" -- version "] Ġas ĠBoolean ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts Help Wrong Opts () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" help Ġ-- un existing - option " ĊĠĠĠ Ġexit . expect System Exit With Status ( 1 ) ĊĠĠĠ Ġparse Opts ( args . simple Split ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts Help Ok () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" help " ĊĠĠĠ Ġval Ġopts Ġ= Ġparse Opts ( args . simple Split ()) ĊĠĠĠ ĠassertTrue ( opts [" help "] Ġas ĠBoolean ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts Version Wrong Opts () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" version Ġ-- un existing - option " ĊĠĠĠ Ġexit . expect System Exit With Status ( 1 ) ĊĠĠĠ Ġparse Opts ( args . simple Split ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts Version Ok () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" version " ĊĠĠĠ Ġval Ġopts Ġ= Ġparse Opts ( args . simple Split ()) ĊĠĠĠ ĠassertTrue ( opts [" version "] Ġas ĠBoolean ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts Serve Wrong Opts () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" serve Ġ-- un existing - option " ĊĠĠĠ Ġexit . expect System Exit With Status ( 1 ) ĊĠĠĠ Ġparse Opts ( args . simple Split ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Parse Opts Serve Ok () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" serve " ĊĠĠĠ Ġval Ġopts Ġ= Ġparse Opts ( args . simple Split ()) ĊĠĠĠ ĠassertTrue ( opts [" serve "] Ġas ĠBoolean ) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Main Help () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" help " ĊĠĠĠ Ġexit . expect System Exit With Status ( 0 ) ĊĠĠĠ Ġmain ( args . simple Split ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġtest Main Version () Ġ{ ĊĠĠĠ Ġval Ġargs Ġ= Ġ" version " ĊĠĠĠ Ġexit . expect System Exit With Status ( 0 ) ĊĠĠĠ Ġmain ( args . simple Split ()) ĊĠ Ġ} Ċ } Ċ