File: JCAMPFile_test.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-11
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 239,924 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; javascript: 164; makefile: 88
file content (111 lines) | stat: -rw-r--r-- 2,566 bytes parent folder | download | duplicates (4)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/CONCEPT/classTest.h>
#include <BALLTestConfig.h>

///////////////////////////

#include <BALL/FORMAT/JCAMPFile.h>

///////////////////////////

START_TEST(class_name)

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////

using namespace BALL;

JCAMPFile* ptr = 0;
CHECK(JCAMPFile() throw())
	ptr = new JCAMPFile;
	TEST_NOT_EQUAL(ptr, 0)
RESULT

CHECK(~JCAMPFile() throw())
	delete ptr;
RESULT

CHECK(JCAMPFile(const String& name, OpenMode open_mode = std::ios::in))
	TEST_EXCEPTION(Exception::FileNotFound, JCAMPFile("asddddddddddddaaaaaaaacasdd"))
	JCAMPFile jcamp(BALL_TEST_DATA_PATH(JCAMPFile_test.dat));
RESULT

CHECK(void read())
	JCAMPFile jcamp(BALL_TEST_DATA_PATH(JCAMPFile_test.dat));
	jcamp.read();

	/*
	StringHashMap<JCAMPFile::JCAMPValue>::Iterator it = jcamp.getEntries().begin();
	for(;+it;++it)
	{
		Log.error() << it->first << "  " << it->second.string_value << "         ";
		if (it->second.numeric_value.size() > 0) Log.error() << it->second.numeric_value[0] << std::endl;
		else Log.error() << std::endl;
	}
	*/
	TEST_EQUAL(jcamp.hasEntry("SYMM"), true)
	TEST_EQUAL(jcamp.getIntValue("SYMM"), 0)
	TEST_EQUAL(jcamp.hasEntry("ML3"), true)
	TEST_REAL_EQUAL(jcamp.getDoubleValue("ML3"), 0.00542953585106775)

	JCAMPFile empty;
	TEST_EXCEPTION(Exception::ParseError, empty.read())
RESULT

CHECK(bool write())
	JCAMPFile jcamp(BALL_TEST_DATA_PATH(JCAMPFile_test.dat));
	jcamp.read();
	jcamp.close();
	String filename;
	NEW_TMP_FILE(filename);
	JCAMPFile out(filename, File::MODE_OUT);
	out.getHeader() = jcamp.getHeader();
	out.getEntries() = jcamp.getEntries();
	out.write();

	JCAMPFile empty;
	TEST_EXCEPTION(File::CannotWrite, empty.write())
RESULT

CHECK(HeaderMap& getHeader() throw())
	// ????
RESULT

CHECK(const HeaderMap& getHeader() const throw())
	// ????
RESULT

CHECK(EntryMap& getEntries() throw())
	// ????
RESULT

CHECK(const EntryMap& getEntries() const throw())
	// ????
RESULT

CHECK(bool hasEntry(const String& name) const throw())
	// ????
RESULT
											
CHECK(Index getIntValue(const String& name) const)
	// ????
RESULT

CHECK(bool hasHeader(const String& name) const throw())
	// ????
RESULT

CHECK(const JCAMPValue& operator [] (const String& name) const)
	// ????
RESULT

CHECK(double getDoubleValue(const String& name) const)
	// ????
RESULT

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST