• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include <iostream>
17 #include <memory>
18 #include <vector>
19 
20 #include "minddata/dataset/core/client.h"
21 #include "common/common.h"
22 #include "utils/ms_utils.h"
23 #include "gtest/gtest.h"
24 #include "utils/log_adapter.h"
25 #include "minddata/dataset/engine/datasetops/source/csv_op.h"
26 #include "minddata/dataset/util/status.h"
27 
28 
29 namespace common = mindspore::common;
30 
31 using namespace mindspore::dataset;
32 using mindspore::MsLogLevel::INFO;
33 using mindspore::ExceptionType::NoExceptionType;
34 using mindspore::LogStream;
35 
36 class MindDataTestCSVOp : public UT::DatasetOpTesting {
37 
38 };
39 
40 TEST_F(MindDataTestCSVOp, TestTotalRows) {
41   std::string csv_file1 = datasets_root_path_ + "/testCSV/1.csv";
42   std::string csv_file2 = datasets_root_path_ + "/testCSV/size.csv";
43   std::vector<std::string> files;
44   files.push_back(csv_file1);
45   int64_t total_rows = 0;
46   CsvOp::CountAllFileRows(files, false, &total_rows);
47   ASSERT_EQ(total_rows, 3);
48   files.clear();
49 
50   files.push_back(csv_file2);
51   CsvOp::CountAllFileRows(files, false, &total_rows);
52   ASSERT_EQ(total_rows, 5);
53   files.clear();
54 
55   files.push_back(csv_file1);
56   files.push_back(csv_file2);
57   CsvOp::CountAllFileRows(files, false, &total_rows);
58   ASSERT_EQ(total_rows, 8);
59   files.clear();
60 }
61