From 19d985856db67d8039332252746895083f699910 Mon Sep 17 00:00:00 2001 From: Behnam Esfahbod Date: Fri, 12 May 2017 12:00:22 -0500 Subject: [PATCH] [tests] Add test for gen_char_from_bidi_class() --- tests/conformance_tests.rs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/conformance_tests.rs b/tests/conformance_tests.rs index 99a174b..65a87dd 100644 --- a/tests/conformance_tests.rs +++ b/tests/conformance_tests.rs @@ -15,7 +15,7 @@ use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; -use unicode_bidi::{BidiInfo, format_chars, Level, process_text}; +use unicode_bidi::{bidi_class, BidiInfo, format_chars, Level, process_text}; const TEST_DATA_DIR: &str = "tests/data"; const BASE_TEST_FILE_NAME: &str = "BidiTest.txt"; @@ -196,3 +196,37 @@ fn gen_char_from_bidi_class(class_name: &str) -> char { &_ => panic!("Invalid Bidi_Class name: {}", class_name), } } + +#[test] +fn test_gen_char_from_bidi_class() { + use unicode_bidi::BidiClass::*; + for class in vec![ + AL, + AN, + B, + BN, + CS, + EN, + ES, + ET, + FSI, + L, + LRE, + LRI, + LRO, + NSM, + ON, + PDF, + PDI, + R, + RLE, + RLI, + RLO, + S, + WS, + ] { + let class_name = format!("{:?}", class); + let sample_char = gen_char_from_bidi_class(&class_name); + assert_eq!(bidi_class(sample_char), class); + } +}