xref: /aoo41x/main/cosv/source/unittest/file_ut.cxx (revision 59617ebc)
1*59617ebcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*59617ebcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*59617ebcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*59617ebcSAndrew Rist  * distributed with this work for additional information
6*59617ebcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*59617ebcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*59617ebcSAndrew Rist  * "License"); you may not use this file except in compliance
9*59617ebcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*59617ebcSAndrew Rist  *
11*59617ebcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*59617ebcSAndrew Rist  *
13*59617ebcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*59617ebcSAndrew Rist  * software distributed under the License is distributed on an
15*59617ebcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*59617ebcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*59617ebcSAndrew Rist  * specific language governing permissions and limitations
18*59617ebcSAndrew Rist  * under the License.
19*59617ebcSAndrew Rist  *
20*59617ebcSAndrew Rist  *************************************************************/
21*59617ebcSAndrew Rist 
22*59617ebcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <precomp.h>
25cdf0e10cSrcweir #include <cosv/file.hxx>
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // NOT FULLY DECLARED SERVICES
28cdf0e10cSrcweir #include <ut.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir using csv::File;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir 
33cdf0e10cSrcweir /** @file
34cdf0e10cSrcweir     UnitTests for class File.
35cdf0e10cSrcweir */
36cdf0e10cSrcweir 
37cdf0e10cSrcweir FUT_DECL( File, Read );
38cdf0e10cSrcweir FUT_DECL( File, Write );
39cdf0e10cSrcweir FUT_DECL( File, Seek );
40cdf0e10cSrcweir FUT_DECL( File, SeekBack );
41cdf0e10cSrcweir FUT_DECL( File, SeekRelative );
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir bool
classtest_File()45cdf0e10cSrcweir classtest_File()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir     csv::File aFile( "bigfile.txt", csv::CFM_RW, 0 );
48cdf0e10cSrcweir     csv::File & rFile = aFile;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     rFile.Open();
51cdf0e10cSrcweir 
52cdf0e10cSrcweir     bool ret = ftest_Read( rFile );
53cdf0e10cSrcweir     ret = ftest_Write( rFile ) AND ret;
54cdf0e10cSrcweir     ret = ftest_SeekBack( rFile ) AND ret;
55cdf0e10cSrcweir     ret = ftest_SeekRelative( rFile ) AND ret;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir     rFile.Close();
58cdf0e10cSrcweir 
59cdf0e10cSrcweir     return ret;
60cdf0e10cSrcweir }
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
FUT_DECL(File,Read)64cdf0e10cSrcweir FUT_DECL( File, Read )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir     bool ret = true;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	rFile.SeekBack(0);
69cdf0e10cSrcweir 	uintt nSourceSize = rFile.Position();
70cdf0e10cSrcweir 	rFile.Seek(0);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     char * pBuf = new char[nSourceSize+1];
73cdf0e10cSrcweir 	uintt nCount = rFile.Read(pBuf,nSourceSize);
74cdf0e10cSrcweir 
75cdf0e10cSrcweir     UT_CHECK( Read, nCount == nSourceSize );
76cdf0e10cSrcweir 
77cdf0e10cSrcweir     return ret;
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
FUT_DECL(File,Write)80cdf0e10cSrcweir FUT_DECL( File, Write )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir     bool ret = true;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     return ret;
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
FUT_DECL(File,Seek)89cdf0e10cSrcweir FUT_DECL( File, Seek )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir     bool ret = true;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
95cdf0e10cSrcweir     return ret;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
FUT_DECL(File,SeekBack)98cdf0e10cSrcweir FUT_DECL( File, SeekBack )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir     bool ret = true;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     return ret;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir 
FUT_DECL(File,SeekRelative)107cdf0e10cSrcweir FUT_DECL( File, SeekRelative )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir     bool ret = true;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 
113cdf0e10cSrcweir     return ret;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 
118