File: test-nist-compounds.php

package info (click to toggle)
xraylib 4.0.0%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 46,936 kB
  • sloc: ansic: 16,103; f90: 8,746; java: 6,766; python: 1,497; cpp: 1,305; pascal: 1,139; makefile: 809; ruby: 622; php: 594; perl: 573; cs: 193; sh: 125
file content (42 lines) | stat: -rw-r--r-- 1,534 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<? 
include("xrltest.php");
include("xraylib.php");

class TestNISTCompounds extends XrlTest {
	function test_good() {
		$list = GetCompoundDataNISTList();
		assertEqual(count($list), 180);
		foreach (array_values($list) as $i => $val) {
			$cdn = GetCompoundDataNISTByIndex($i);
			assertEqual($cdn['name'], $val);
			$cdn = GetCompoundDataNISTByName($val);
			assertEqual($cdn['name'], $val);
		}
		$cdn = GetCompoundDataNISTByIndex(5);
		assertEqual($cdn['nElements'], 4);
		assertAlmostEqual($cdn['density'], 0.001205);
		assertEqual($cdn['Elements'], array(6, 7, 8, 18));
		assertAlmostEqual($cdn['massFractions'], array(0.000124, 0.755267, 0.231781, 0.012827));
		assertEqual($cdn['name'], "Air, Dry (near sea level)");

		$cdn = GetCompoundDataNISTByName("Air, Dry (near sea level)");
		assertEqual($cdn['nElements'], 4);
		assertAlmostEqual($cdn['density'], 0.001205);
		assertEqual($cdn['Elements'], array(6, 7, 8, 18));
		assertAlmostEqual($cdn['massFractions'], array(0.000124, 0.755267, 0.231781, 0.012827));
		assertEqual($cdn['name'], "Air, Dry (near sea level)");
	}
	function test_bad() {
		assertException(ValueError, "GetCompoundDataNISTByName", "jjwqfejfjf");
		assertException(ValueError, "GetCompoundDataNISTByName", 0);
		assertException(ValueError, "GetCompoundDataNISTByName", NULL);
		assertException(ValueError, "GetCompoundDataNISTByIndex", -1);
		assertException(ValueError, "GetCompoundDataNISTByIndex", 180);
	}
}

$suite = new XrlTestSuite();
$suite->append(new TestNISTCompounds());
$suite->run();

?>