libStatGen Software 1
ReadFiles.cpp
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "ReadFiles.h"
19#include "Validate.h"
20#include "GlfException.h"
21#include <assert.h>
22
23void testReadGlf()
24{
25 GlfFile inGlf;
26 assert(inGlf.openForRead("testFiles/testGlf.glf"));
27
28 // Read the GLF Header.
29 GlfHeader glfHeader;
30 assert(inGlf.readHeader(glfHeader));
31
32 validateHeader(glfHeader);
33
34 // TODO, validate the rest of the file.
35// GlfRecord glfRecord;
36// assert(inGlf.ReadRecord(glfHeader, glfRecord) == true);
37// validateRead1(glfRecord);
38
39 // Try opening a file that doesn't exist.
40 bool exceptionCaught = false;
41 try
42 {
43 inGlf.openForRead("testFiles/unknown");
44 }
45 catch(GlfException e)
46 {
47 exceptionCaught = true;
48 }
49 assert(exceptionCaught);
50
51
52}
53
GlfException objects should be thrown by functions that operate on Glf files for exceptions.
Definition: GlfException.h:28
This class allows a user to easily read/write a GLF file.
Definition: GlfFile.h:29
bool openForRead(const char *filename)
Open a glf file for reading with the specified filename.
Definition: GlfFile.cpp:66
bool readHeader(GlfHeader &header)
Reads the header section from the file and stores it in the passed in header.
Definition: GlfFile.cpp:165
This class allows a user to easily get/set the fields in a GLF header.
Definition: GlfHeader.h:30