Skip to content

Commit 42853ce

Browse files
committed
add unit test for check_record_delimiter using OpenAI's GPT-3
1 parent da68266 commit 42853ce

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/query/formats/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ pub use field_decoder::*;
2828
pub use file_format_type::parse_timezone;
2929
pub use file_format_type::FileFormatOptionsExt;
3030
pub use file_format_type::FileFormatTypeExt;
31+
pub use format_option_checker::check_record_delimiter;
3132

3233
use crate::common_settings::CommonSettings;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2022 Datafuse Labs.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
use common_formats::check_record_delimiter;
16+
17+
/// This test code is written by OpenAI's GPT-3.
18+
#[test]
19+
fn test_check_record_delimiter() {
20+
let mut option = "".to_string();
21+
assert!(check_record_delimiter(&mut option).is_ok());
22+
assert_eq!(option, "\n");
23+
24+
let mut option = "|".to_string();
25+
assert!(check_record_delimiter(&mut option).is_ok());
26+
assert_eq!(option, "|");
27+
28+
let mut option = "\r\n".to_string();
29+
assert!(check_record_delimiter(&mut option).is_ok());
30+
assert_eq!(option, "\r\n");
31+
32+
let mut option = "foo".to_string();
33+
assert!(check_record_delimiter(&mut option).is_err());
34+
35+
let mut option = "|\r".to_string();
36+
assert!(check_record_delimiter(&mut option).is_err());
37+
}

src/query/formats/tests/it/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use common_meta_types::StageFileFormatType;
2121
use common_settings::Settings;
2222

2323
mod field_encoder;
24+
mod format_option_checker;
2425
mod output_format_json_each_row;
2526
mod output_format_tcsv;
2627
mod output_format_utils;

0 commit comments

Comments
 (0)