source: proiecte/HadoopJUnit/hadoop-0.20.1/src/c++/librecordio/test/testFromJava.cc @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 2.1 KB
Line 
1/**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#include "test.hh"
20
21int main()
22{
23  org::apache::hadoop::record::test::RecRecord1 r1;
24  org::apache::hadoop::record::test::RecRecord1 r2;
25  r1.setBoolVal(true);
26  r1.setByteVal((int8_t)0x66);
27  r1.setFloatVal(3.145);
28  r1.setDoubleVal(1.5234);
29  r1.setIntVal(4567);
30  r1.setLongVal(0x5a5a5a5a5a5aLL);
31  std::string& s = r1.getStringVal();
32  s = "random text";
33  {
34    hadoop::FileInStream istream;
35    istream.open("/tmp/hadooptemp.dat");
36    hadoop::RecordReader reader(istream, hadoop::kBinary);
37    reader.read(r2);
38    if (r1 == r2) {
39      printf("Binary archive test passed.\n");
40    } else {
41      printf("Binary archive test failed.\n");
42    }
43    istream.close();
44  }
45  {
46    hadoop::FileInStream istream;
47    istream.open("/tmp/hadooptemp.txt");
48    hadoop::RecordReader reader(istream, hadoop::kCSV);
49    reader.read(r2);
50    if (r1 == r2) {
51      printf("CSV archive test passed.\n");
52    } else {
53      printf("CSV archive test failed.\n");
54    }
55    istream.close();
56  }
57  {
58    hadoop::FileInStream istream;
59    istream.open("/tmp/hadooptemp.xml");
60    hadoop::RecordReader reader(istream, hadoop::kXML);
61    reader.read(r2);
62    if (r1 == r2) {
63      printf("XML archive test passed.\n");
64    } else {
65      printf("XML archive test failed.\n");
66    }
67    istream.close();
68  }
69  return 0;
70}
71
Note: See TracBrowser for help on using the repository browser.