1 // Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu>
2 //
3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 // option. This file may not be copied, modified, or distributed
7 // except according to those terms.
8 
9 #[macro_use]
10 extern crate structopt;
11 
12 use structopt::StructOpt;
13 
14 #[test]
no_author_version_about()15 fn no_author_version_about() {
16     #[derive(StructOpt, PartialEq, Debug)]
17     #[structopt(name = "foo", about = "", author = "", version = "")]
18     struct Opt {}
19 
20     let mut output = Vec::new();
21     Opt::clap().write_long_help(&mut output).unwrap();
22     let output = String::from_utf8(output).unwrap();
23 
24     assert!(output.starts_with("foo \n\nUSAGE:"));
25 }
26 
27 #[test]
use_env()28 fn use_env() {
29     #[derive(StructOpt, PartialEq, Debug)]
30     #[structopt()]
31     struct Opt {}
32 
33     let mut output = Vec::new();
34     Opt::clap().write_long_help(&mut output).unwrap();
35     let output = String::from_utf8(output).unwrap();
36     assert!(output.starts_with("structopt 0.2."));
37     assert!(output.contains("Guillaume Pinot <texitoi@texitoi.eu>, others"));
38     assert!(output.contains("Parse command line argument by defining a struct."));
39 }
40