File indexing completed on 2024-11-24 04:54:32

0001 /*
0002     SPDX-License-Identifier: MPL-2.0
0003 */
0004 
0005 /* Copyright (c) 2015 Brian R. Bondy. Distributed under the MPL2 license.
0006  * This Source Code Form is subject to the terms of the Mozilla Public
0007  * License, v. 2.0. If a copy of the MPL was not distributed with this
0008  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
0009 
0010 #include <fstream>
0011 #include <sstream>
0012 #include <iostream>
0013 #include <string>
0014 #include "./CppUnitLite/TestHarness.h"
0015 #include "./test/util.h"
0016 
0017 using std::cout;
0018 using std::endl;
0019 
0020 std::string getFileContents(const char *filename) {
0021   std::ifstream in(filename, std::ios::in);
0022   if (in) {
0023     std::ostringstream contents;
0024     contents << in.rdbuf();
0025     in.close();
0026     return(contents.str());
0027   }
0028   throw(errno);
0029 }
0030 
0031 bool compareNums(int actual, int expected) {
0032   if (actual != expected) {
0033     cout << "Actual: " << actual << endl << "Expected: " << expected << endl;
0034     return false;
0035   }
0036   return true;
0037 }