| 1 |
#! /usr/bin/perl -w |
| 2 |
# Before `make install' is performed this script should be runnable with |
| 3 |
# `make test'. After `make install' it should work as `perl test.pl' |
| 4 |
|
| 5 |
######################### We start with some black magic to print on failure. |
| 6 |
|
| 7 |
# Change 1..1 below to 1..last_test_to_print . |
| 8 |
# (It may become useful if the test is moved to ./t subdirectory.) |
| 9 |
|
| 10 |
BEGIN { $| = 1; print "1..27$/"; } |
| 11 |
END {print "not ok 1$/" unless $loaded;} |
| 12 |
use Xray::Xtal; |
| 13 |
$Xray::Xtal::run_level = 3; |
| 14 |
$loaded = 1; |
| 15 |
print "ok 1$/"; |
| 16 |
|
| 17 |
######################### End of black magic. |
| 18 |
|
| 19 |
# Insert your test code below (better if it prints "ok 13" |
| 20 |
# (correspondingly "not ok 13") depending on the success of chunk 13 |
| 21 |
# of the test code): |
| 22 |
|
| 23 |
|
| 24 |
## the purpose of this test is to probe the various ways of specifying |
| 25 |
## a space group |
| 26 |
|
| 27 |
@pm3m = ("p m -3 M", # 2. test the symbol itself |
| 28 |
"p m 3 m", # 3. test the 1935 symbol |
| 29 |
221, # 4. the number |
| 30 |
"o_h^1", # 5. schoenflies |
| 31 |
"o^1_h", # 6. schoenflies, the other way |
| 32 |
"p 4/m -3 2/m", # 7. the full symbol |
| 33 |
"P M -3 M", # 8. case |
| 34 |
"p m -3 m", # 9. extra spaces |
| 35 |
" p m -3 m", # 10. leading spaces |
| 36 |
"p m -3 m ", # 11. trailing spaces |
| 37 |
"p m -3 m", # 12. tabs & spaces |
| 38 |
"pm-3m", # 13. no spaces |
| 39 |
"pm3m", # 14. no spaces |
| 40 |
"perovskite" # 15. shorthand |
| 41 |
); |
| 42 |
|
| 43 |
$n = 1; |
| 44 |
while (@pm3m) { |
| 45 |
$this = shift @pm3m; |
| 46 |
++$n; |
| 47 |
$cell = Xray::Xtal::Cell -> new() -> make(Space_group => $this); |
| 48 |
($group) = $cell -> attributes("Space_group"); |
| 49 |
if ($group eq "p m -3 m") { |
| 50 |
print "ok $n$/"; |
| 51 |
} else { |
| 52 |
print "not ok $n$/"; |
| 53 |
}; |
| 54 |
undef $cell; |
| 55 |
}; |
| 56 |
|
| 57 |
@cm = ("c m", # 16. the symbol |
| 58 |
"a m", # 17. a short monoclinic symbol |
| 59 |
"a 1 1 m",); # 18. a full monoclinic setting |
| 60 |
while (@cm) { |
| 61 |
$this = shift @cm; |
| 62 |
++$n; |
| 63 |
$cell = Xray::Xtal::Cell -> new() -> make(Space_group => $this); |
| 64 |
($group) = $cell -> attributes("Space_group"); |
| 65 |
if ($group eq "c m") { |
| 66 |
print "ok $n$/"; |
| 67 |
} else { |
| 68 |
print "not ok $n$/"; |
| 69 |
}; |
| 70 |
undef $cell; |
| 71 |
}; |
| 72 |
|
| 73 |
@abm2 = ("a b m 2", # 19. the symbol |
| 74 |
"a e m 2",); # 20. double glide plane symbol |
| 75 |
while (@abm2) { |
| 76 |
$this = shift @abm2; |
| 77 |
++$n; |
| 78 |
$cell = Xray::Xtal::Cell -> new() -> make(Space_group => $this); |
| 79 |
($group) = $cell -> attributes("Space_group"); |
| 80 |
if ($group eq "a b m 2") { |
| 81 |
print "ok $n$/"; |
| 82 |
} else { |
| 83 |
print "not ok $n$/"; |
| 84 |
}; |
| 85 |
undef $cell; |
| 86 |
}; |
| 87 |
|
| 88 |
%schoen = ("V_3^3" => "p 31 1 2", # 21. V groups |
| 89 |
"D_ 3^ 3" => "p 31 1 2", # 22. spaces in the schoenflies symbol |
| 90 |
); |
| 91 |
while (($key, $val) = each %schoen) { |
| 92 |
++$n; |
| 93 |
$cell = Xray::Xtal::Cell -> new() -> make(Space_group => $key); |
| 94 |
($group) = $cell -> attributes("Space_group"); |
| 95 |
if ($group eq $val) { |
| 96 |
print "ok $n$/"; |
| 97 |
} else { |
| 98 |
print "not ok $n$/"; |
| 99 |
}; |
| 100 |
undef $cell; |
| 101 |
}; |
| 102 |
|
| 103 |
# 23. Miscellany |
| 104 |
%misc = ("p 63 / m c m" => "p 63/m c m", # 23: slashes with spaces |
| 105 |
); |
| 106 |
while (($key, $val) = each %misc) { |
| 107 |
++$n; |
| 108 |
$cell = Xray::Xtal::Cell -> new() -> make(Space_group => $key); |
| 109 |
($group) = $cell -> attributes("Space_group"); |
| 110 |
if ($group eq $val) { |
| 111 |
print "ok $n$/"; |
| 112 |
} else { |
| 113 |
print "not ok $n$/"; |
| 114 |
}; |
| 115 |
undef $cell; |
| 116 |
}; |
| 117 |
|
| 118 |
# 24-27. Various things that aren't symbols |
| 119 |
@not = ("p m -3 q", 0, "o_h^127", "hi mom!"); |
| 120 |
while (@not) { |
| 121 |
$this = shift @not; |
| 122 |
++$n; |
| 123 |
$cell = Xray::Xtal::Cell -> new() -> make(Space_group => $this); |
| 124 |
($group) = $cell -> attributes("Space_group"); |
| 125 |
if ($group eq "0") { |
| 126 |
print "ok $n$/"; |
| 127 |
} else { |
| 128 |
print "not ok $n$/"; |
| 129 |
}; |
| 130 |
undef $cell; |
| 131 |
}; |