use opensmiles::parse;
#[test]
fn display_simple_methane() {
let mol = parse("C").unwrap();
assert_eq!(format!("{}", mol), "C");
}
#[test]
fn display_bracket_methane() {
let mol = parse("[CH4]").unwrap();
assert_eq!(format!("{}", mol), "C");
}
#[test]
fn display_ethane() {
let mol = parse("CC").unwrap();
assert_eq!(format!("{}", mol), "CC");
}
#[test]
fn display_ethanol() {
let mol = parse("CCO").unwrap();
assert_eq!(format!("{}", mol), "OCC");
}
#[test]
fn display_methanone() {
let mol = parse("C=O").unwrap();
assert_eq!(format!("{}", mol), "O=C");
}
#[test]
fn display_methylamine() {
let mol = parse("C#N").unwrap();
assert_eq!(format!("{}", mol), "N#C");
}
#[test]
fn display_branch() {
let mol = parse("CC(C)C").unwrap();
assert_eq!(format!("{}", mol), "CC(C)C");
}
#[test]
fn display_branch_with_bond() {
let mol = parse("CC(=O)O").unwrap();
assert_eq!(format!("{}", mol), "O=C(C)O");
}
#[test]
fn display_benzene() {
let mol = parse("C1CCCCC1").unwrap();
assert_eq!(format!("{}", mol), "C1CCCCC1");
}
#[test]
fn display_benzene_with_unstandard_cycle_number() {
let mol = parse("C4CCCCC4").unwrap();
assert_eq!(format!("{}", mol), "C1CCCCC1");
}
#[test]
fn display_aromatic_cycle() {
let mol = parse("c1ccccc1").unwrap();
assert_eq!(format!("{}", mol), "c1ccccc1");
}
#[test]
fn display_toluene() {
let mol = parse("Cc1ccccc1").unwrap();
assert_eq!(format!("{}", mol), "Cc1ccccc1");
}
#[test]
fn display_neopentane() {
let mol = parse("CC(C)(C)C").unwrap();
assert_eq!(format!("{}", mol), "CC(C)(C)C");
}
#[test]
fn display_acetate_ion() {
let mol = parse("CC(=O)[O-]").unwrap();
assert_eq!(format!("{}", mol), "O=C(C)[O-]");
}
#[test]
fn display_sodium_ion() {
let mol = parse("[Na+]").unwrap();
assert_eq!(format!("{}", mol), "[Na+]");
}
#[test]
fn display_cyclohexanone() {
let mol = parse("O=C1CCCCC1").unwrap();
assert_eq!(format!("{}", mol), "O=C1CCCCC1");
}
#[test]
fn display_naphthalene() {
let mol = parse("c1ccc2ccccc2c1").unwrap();
assert_eq!(format!("{}", mol), "c1ccc2ccccc2c1");
}
#[test]
fn display_aspirin() {
let mol = parse("CC(=O)Oc1ccccc1C(=O)O").unwrap();
assert_eq!(format!("{}", mol), "O=C(C)Oc1ccccc1C(=O)O");
}
#[test]
fn display_trans_2_butene() {
let mol = parse("C/C=C/C").unwrap();
assert_eq!(format!("{}", mol), "C/C=C/C");
}
#[test]
fn display_cis_2_butene() {
let mol = parse("C/C=C\\C").unwrap();
assert_eq!(format!("{}", mol), "C/C=C\\C");
}
#[test]
fn display_chiral_carbon() {
let mol = parse("[C@@H](F)(Cl)Br").unwrap();
assert_eq!(format!("{}", mol), "F[C@@H](Cl)Br");
}
#[test]
fn display_isotope() {
let mol = parse("[13C]").unwrap();
assert_eq!(format!("{}", mol), "[13C]");
}
#[test]
fn display_two_digits_ring_number_must_begin_with_percent_symbol() {
let mol = parse("c1ccccc1Cc2ccccc2Cc3ccccc3Cc4ccccc4Cc5ccccc5Cc6ccccc6Cc7ccccc7Cc8ccccc8Cc9ccccc9Cc%10ccccc%10").unwrap();
assert_eq!(format!("{}", mol), "c1ccccc1Cc2ccccc2Cc3ccccc3Cc4ccccc4Cc5ccccc5Cc6ccccc6Cc7ccccc7Cc8ccccc8Cc9ccccc9Cc%10ccccc%10");
}
#[test]
fn display_standard_form_atoms() {
let mol1 = parse("[CH3][CH3]").unwrap();
assert_eq!(format!("{}", mol1), "CC");
let mol2 = parse("[CH3-1]").unwrap();
assert_eq!(format!("{}", mol2), "[CH3-]");
let mol3 = parse("C[13CH1](C)C").unwrap();
assert_eq!(format!("{}", mol3), "C[13CH](C)C");
let mol4 = parse("[C-H3]").unwrap();
assert_eq!(format!("{}", mol4), "[CH3-]");
let mol5 = parse("F[CH@](Br)Cl").unwrap();
assert_eq!(format!("{}", mol5), "F[C@H](Br)Cl");
let mol6 = parse("[H][C-]([H])[H]").unwrap();
assert_eq!(format!("{}", mol6), "[CH3-]");
}
#[test]
fn display_standard_form_bonds() {
let mol1 = parse("C-C").unwrap();
assert_eq!(format!("{}", mol1), "CC");
let mol2 = parse("c:1:c:c:c:c:c:1").unwrap();
assert_eq!(format!("{}", mol2), "c1ccccc1");
let mol3 = parse("c1ccccc1c2ccccc2").unwrap();
assert_eq!(format!("{}", mol3), "c1ccccc1-c2ccccc2");
}
#[test]
fn display_standard_form_cycles() {
let mol1 = parse("c1ccccc1C1CCCC1").unwrap();
assert_eq!(format!("{}", mol1), "c1ccccc1C2CCCC2");
let mol2 = parse("c0ccccc0C1CCCC1").unwrap();
assert_eq!(format!("{}", mol2), "c1ccccc1C2CCCC2");
let mol3 = parse("CC=1CCCCC=1").unwrap();
assert_eq!(format!("{}", mol3), "CC1=CCCCC1");
let mol4 = parse("C12(CCCCC1)CCCCC2").unwrap();
assert_eq!(format!("{}", mol4), "C1C2(CCCC1)CCCCC2");
let mol5 = parse("C%01CCCCC%01").unwrap();
assert_eq!(format!("{}", mol5), "C1CCCCC1");
}
#[test]
fn display_standard_form_branches() {
let mol1 = parse("c1cc(CO)ccc1").unwrap();
assert_eq!(format!("{}", mol1), "OCc1ccccc1");
let mol2 = parse("CC(CCCCCC)C").unwrap();
assert_eq!(format!("{}", mol2), "CC(C)CCCCCC");
let mol3 = parse("CCCO").unwrap();
assert_eq!(format!("{}", mol3), "OCCC");
let mol4 = parse("C1.C1").unwrap();
assert_eq!(format!("{}", mol4), "CC");
}
#[test]
fn display_standard_form_aromaticity() {
let mol1 = parse("C1=CC=CC=C1").unwrap();
assert_eq!(format!("{}", mol1), "c1ccccc1");
}
#[test]
fn display_standard_form_chirality() {
let mol1 = parse("Br[C@H](Br)C").unwrap();
assert_eq!(format!("{}", mol1), "BrC(Br)C");
let mol2 = parse("F/C(/F)=C/F").unwrap();
assert_eq!(format!("{}", mol2), "FC(F)=CF");
}