88// except according to those terms.
99
1010#![ cfg( test) ]
11-
1211#![ deny( warnings) ]
1312#![ allow( non_upper_case_globals) ]
14-
1513#![ cfg_attr( feature = "unstable" , feature( test) ) ]
1614
1715extern crate string_cache;
1816
19- #[ cfg( feature = "unstable" ) ] extern crate test;
20- #[ cfg( feature = "unstable" ) ] extern crate rand;
17+ #[ cfg( feature = "unstable" ) ]
18+ extern crate rand;
19+ #[ cfg( feature = "unstable" ) ]
20+ extern crate test;
2121
2222use std:: thread;
2323use string_cache:: atom:: StaticAtomSet ;
@@ -157,32 +157,32 @@ macro_rules! assert_eq_fmt (($fmt:expr, $x:expr, $y:expr) => ({
157157#[ test]
158158fn repr ( ) {
159159 fn check ( s : & str , data : u64 ) {
160- assert_eq_fmt ! ( "0x{:016X}" , Atom :: from( s) . unsafe_data, data) ;
160+ assert_eq_fmt ! ( "0x{:016X}" , Atom :: from( s) . unsafe_data( ) , data) ;
161161 }
162162
163163 fn check_static ( s : & str , x : Atom ) {
164- assert_eq_fmt ! ( "0x{:016X}" , x. unsafe_data, Atom :: from( s) . unsafe_data) ;
165- assert_eq ! ( 0x2 , x. unsafe_data & 0xFFFF_FFFF ) ;
164+ assert_eq_fmt ! ( "0x{:016X}" , x. unsafe_data( ) , Atom :: from( s) . unsafe_data( ) ) ;
165+ assert_eq ! ( 0x2 , x. unsafe_data( ) & 0xFFFF_FFFF ) ;
166166 // The index is unspecified by phf.
167- assert ! ( ( x. unsafe_data >> 32 ) <= TestAtomStaticSet :: get( ) . atoms. len( ) as u64 ) ;
167+ assert ! ( ( x. unsafe_data( ) >> 32 ) <= TestAtomStaticSet :: get( ) . atoms. len( ) as u64 ) ;
168168 }
169169
170170 // This test is here to make sure we don't change atom representation
171171 // by accident. It may need adjusting if there are changes to the
172172 // static atom table, the tag values, etc.
173173
174174 // Static atoms
175- check_static ( "a" , test_atom ! ( "a" ) ) ;
175+ check_static ( "a" , test_atom ! ( "a" ) ) ;
176176 check_static ( "address" , test_atom ! ( "address" ) ) ;
177- check_static ( "area" , test_atom ! ( "area" ) ) ;
177+ check_static ( "area" , test_atom ! ( "area" ) ) ;
178178
179179 // Inline atoms
180- check ( "e" , 0x0000_0000_0000_6511 ) ;
181- check ( "xyzzy" , 0x0000_797A_7A79_7851 ) ;
180+ check ( "e" , 0x0000_0000_0000_6511 ) ;
181+ check ( "xyzzy" , 0x0000_797A_7A79_7851 ) ;
182182 check ( "xyzzy01" , 0x3130_797A_7A79_7871 ) ;
183183
184184 // Dynamic atoms. This is a pointer so we can't verify every bit.
185- assert_eq ! ( 0x00 , Atom :: from( "a dynamic string" ) . unsafe_data & 0xf ) ;
185+ assert_eq ! ( 0x00 , Atom :: from( "a dynamic string" ) . unsafe_data( ) & 0xf ) ;
186186}
187187
188188#[ test]
@@ -203,23 +203,32 @@ fn atom_macro() {
203203
204204#[ test]
205205fn match_atom ( ) {
206- assert_eq ! ( 2 , match Atom :: from( "head" ) {
207- test_atom!( "br" ) => 1 ,
208- test_atom!( "html" ) | test_atom!( "head" ) => 2 ,
209- _ => 3 ,
210- } ) ;
211-
212- assert_eq ! ( 3 , match Atom :: from( "body" ) {
213- test_atom!( "br" ) => 1 ,
214- test_atom!( "html" ) | test_atom!( "head" ) => 2 ,
215- _ => 3 ,
216- } ) ;
217-
218- assert_eq ! ( 3 , match Atom :: from( "zzzzzz" ) {
219- test_atom!( "br" ) => 1 ,
220- test_atom!( "html" ) | test_atom!( "head" ) => 2 ,
221- _ => 3 ,
222- } ) ;
206+ assert_eq ! (
207+ 2 ,
208+ match Atom :: from( "head" ) {
209+ test_atom!( "br" ) => 1 ,
210+ test_atom!( "html" ) | test_atom!( "head" ) => 2 ,
211+ _ => 3 ,
212+ }
213+ ) ;
214+
215+ assert_eq ! (
216+ 3 ,
217+ match Atom :: from( "body" ) {
218+ test_atom!( "br" ) => 1 ,
219+ test_atom!( "html" ) | test_atom!( "head" ) => 2 ,
220+ _ => 3 ,
221+ }
222+ ) ;
223+
224+ assert_eq ! (
225+ 3 ,
226+ match Atom :: from( "zzzzzz" ) {
227+ test_atom!( "br" ) => 1 ,
228+ test_atom!( "html" ) | test_atom!( "head" ) => 2 ,
229+ _ => 3 ,
230+ }
231+ ) ;
223232}
224233
225234#[ test]
@@ -240,29 +249,43 @@ fn ensure_as_ref() {
240249fn test_ascii_lowercase ( ) {
241250 assert_eq ! ( Atom :: from( "" ) . to_ascii_lowercase( ) , Atom :: from( "" ) ) ;
242251 assert_eq ! ( Atom :: from( "aZ9" ) . to_ascii_lowercase( ) , Atom :: from( "az9" ) ) ;
243- assert_eq ! ( Atom :: from( "The Quick Brown Fox!" ) . to_ascii_lowercase( ) , Atom :: from( "the quick brown fox!" ) ) ;
244- assert_eq ! ( Atom :: from( "JE VAIS À PARIS" ) . to_ascii_lowercase( ) , Atom :: from( "je vais À paris" ) ) ;
252+ assert_eq ! (
253+ Atom :: from( "The Quick Brown Fox!" ) . to_ascii_lowercase( ) ,
254+ Atom :: from( "the quick brown fox!" )
255+ ) ;
256+ assert_eq ! (
257+ Atom :: from( "JE VAIS À PARIS" ) . to_ascii_lowercase( ) ,
258+ Atom :: from( "je vais À paris" )
259+ ) ;
245260}
246261
247262#[ test]
248263fn test_ascii_uppercase ( ) {
249264 assert_eq ! ( Atom :: from( "" ) . to_ascii_uppercase( ) , Atom :: from( "" ) ) ;
250265 assert_eq ! ( Atom :: from( "aZ9" ) . to_ascii_uppercase( ) , Atom :: from( "AZ9" ) ) ;
251- assert_eq ! ( Atom :: from( "The Quick Brown Fox!" ) . to_ascii_uppercase( ) , Atom :: from( "THE QUICK BROWN FOX!" ) ) ;
252- assert_eq ! ( Atom :: from( "Je vais à Paris" ) . to_ascii_uppercase( ) , Atom :: from( "JE VAIS à PARIS" ) ) ;
266+ assert_eq ! (
267+ Atom :: from( "The Quick Brown Fox!" ) . to_ascii_uppercase( ) ,
268+ Atom :: from( "THE QUICK BROWN FOX!" )
269+ ) ;
270+ assert_eq ! (
271+ Atom :: from( "Je vais à Paris" ) . to_ascii_uppercase( ) ,
272+ Atom :: from( "JE VAIS à PARIS" )
273+ ) ;
253274}
254275
255276#[ test]
256277fn test_eq_ignore_ascii_case ( ) {
257278 assert ! ( Atom :: from( "" ) . eq_ignore_ascii_case( & Atom :: from( "" ) ) ) ;
258279 assert ! ( Atom :: from( "aZ9" ) . eq_ignore_ascii_case( & Atom :: from( "aZ9" ) ) ) ;
259280 assert ! ( Atom :: from( "aZ9" ) . eq_ignore_ascii_case( & Atom :: from( "Az9" ) ) ) ;
260- assert ! ( Atom :: from( "The Quick Brown Fox!" ) . eq_ignore_ascii_case( & Atom :: from( "THE quick BROWN fox!" ) ) ) ;
281+ assert ! ( Atom :: from( "The Quick Brown Fox!" )
282+ . eq_ignore_ascii_case( & Atom :: from( "THE quick BROWN fox!" ) ) ) ;
261283 assert ! ( Atom :: from( "Je vais à Paris" ) . eq_ignore_ascii_case( & Atom :: from( "je VAIS à PARIS" ) ) ) ;
262284 assert ! ( !Atom :: from( "" ) . eq_ignore_ascii_case( & Atom :: from( "az9" ) ) ) ;
263285 assert ! ( !Atom :: from( "aZ9" ) . eq_ignore_ascii_case( & Atom :: from( "" ) ) ) ;
264286 assert ! ( !Atom :: from( "aZ9" ) . eq_ignore_ascii_case( & Atom :: from( "9Za" ) ) ) ;
265- assert ! ( !Atom :: from( "The Quick Brown Fox!" ) . eq_ignore_ascii_case( & Atom :: from( "THE quick BROWN fox!!" ) ) ) ;
287+ assert ! ( !Atom :: from( "The Quick Brown Fox!" )
288+ . eq_ignore_ascii_case( & Atom :: from( "THE quick BROWN fox!!" ) ) ) ;
266289 assert ! ( !Atom :: from( "Je vais à Paris" ) . eq_ignore_ascii_case( & Atom :: from( "JE vais À paris" ) ) ) ;
267290}
268291
0 commit comments