Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CMake
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mattias Ellert
CMake
Commits
4226c83f
Commit
4226c83f
authored
9 years ago
by
Brad King
Committed by
Kitware Robot
9 years ago
Browse files
Options
Downloads
Plain Diff
Merge topic 'update-kwsys'
0a5ce85f
Merge branch 'upstream-KWSys' into update-kwsys
f2b0bf6e
KWSys 2016-01-07 (2418443e)
parents
963d99de
0a5ce85f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Source/kwsys/FStream.cxx
+2
-0
2 additions, 0 deletions
Source/kwsys/FStream.cxx
Source/kwsys/testFStream.cxx
+14
-65
14 additions, 65 deletions
Source/kwsys/testFStream.cxx
with
16 additions
and
65 deletions
Source/kwsys/FStream.cxx
+
2
−
0
View file @
4226c83f
...
...
@@ -34,6 +34,7 @@ BOM ReadBOM(std::istream& in)
in
.
read
(
reinterpret_cast
<
char
*>
(
bom
),
2
);
if
(
!
in
.
good
())
{
in
.
clear
();
in
.
seekg
(
orig
);
return
BOM_None
;
}
...
...
@@ -68,6 +69,7 @@ BOM ReadBOM(std::istream& in)
in
.
seekg
(
p
);
return
BOM_UTF16LE
;
}
in
.
clear
();
in
.
seekg
(
orig
);
return
BOM_None
;
}
...
...
This diff is collapsed.
Click to expand it.
Source/kwsys/testFStream.cxx
+
14
−
65
View file @
4226c83f
...
...
@@ -41,8 +41,13 @@ static int testNoFile()
return
0
;
}
static
kwsys
::
FStream
::
BOM
expected_bom
[
5
]
=
static
const
int
num_test_files
=
7
;
static
const
int
max_test_file_size
=
45
;
static
kwsys
::
FStream
::
BOM
expected_bom
[
num_test_files
]
=
{
kwsys
::
FStream
::
BOM_None
,
kwsys
::
FStream
::
BOM_None
,
kwsys
::
FStream
::
BOM_UTF8
,
kwsys
::
FStream
::
BOM_UTF16LE
,
kwsys
::
FStream
::
BOM_UTF16BE
,
...
...
@@ -50,8 +55,10 @@ static kwsys::FStream::BOM expected_bom[5] =
kwsys
::
FStream
::
BOM_UTF32BE
};
static
unsigned
char
expected_bom_data
[
5
][
5
]
=
static
unsigned
char
expected_bom_data
[
num_test_files
][
5
]
=
{
{
0
},
{
0
},
{
3
,
0xEF
,
0xBB
,
0xBF
},
{
2
,
0xFF
,
0xFE
},
{
2
,
0xFE
,
0xFF
},
...
...
@@ -59,8 +66,10 @@ static unsigned char expected_bom_data[5][5] =
{
4
,
0x00
,
0x00
,
0xFE
,
0xFF
},
};
static
unsigned
char
file_data
[
5
][
45
]
=
static
unsigned
char
file_data
[
num_test_files
][
max_test_file_size
]
=
{
{
1
,
'H'
},
{
11
,
'H'
,
'e'
,
'l'
,
'l'
,
'o'
,
' '
,
'W'
,
'o'
,
'r'
,
'l'
,
'd'
},
{
11
,
'H'
,
'e'
,
'l'
,
'l'
,
'o'
,
' '
,
'W'
,
'o'
,
'r'
,
'l'
,
'd'
},
{
22
,
0x48
,
0x00
,
0x65
,
0x00
,
0x6C
,
0x00
,
0x6C
,
0x00
,
0x6F
,
0x00
,
0x20
,
0x00
,
0x57
,
0x00
,
0x6F
,
0x00
,
0x72
,
0x00
,
0x6C
,
0x00
,
0x64
,
0x00
},
...
...
@@ -80,7 +89,7 @@ static unsigned char file_data[5][45] =
static
int
testBOM
()
{
// test various encodings in binary mode
for
(
int
i
=
0
;
i
<
5
;
i
++
)
for
(
int
i
=
0
;
i
<
num_test_files
;
i
++
)
{
{
kwsys
::
ofstream
out
(
"bom.txt"
,
kwsys
::
ofstream
::
binary
);
...
...
@@ -97,7 +106,7 @@ static int testBOM()
std
::
cout
<<
"Unexpected BOM "
<<
i
<<
std
::
endl
;
return
1
;
}
char
data
[
45
];
char
data
[
max_test_file_size
];
in
.
read
(
data
,
file_data
[
i
][
0
]);
if
(
!
in
.
good
())
{
...
...
@@ -113,66 +122,6 @@ static int testBOM()
}
// test text file without bom
{
{
kwsys
::
ofstream
out
(
"bom.txt"
);
out
<<
"Hello World"
;
}
kwsys
::
ifstream
in
(
"bom.txt"
);
kwsys
::
FStream
::
BOM
bom
=
kwsys
::
FStream
::
ReadBOM
(
in
);
if
(
bom
!=
kwsys
::
FStream
::
BOM_None
)
{
std
::
cout
<<
"Unexpected BOM for none case"
<<
std
::
endl
;
return
1
;
}
char
data
[
45
];
in
.
read
(
data
,
file_data
[
0
][
0
]);
if
(
!
in
.
good
())
{
std
::
cout
<<
"Unable to read data for none case"
<<
std
::
endl
;
return
1
;
}
if
(
memcmp
(
data
,
file_data
[
0
]
+
1
,
file_data
[
0
][
0
])
!=
0
)
{
std
::
cout
<<
"Incorrect read data for none case"
<<
std
::
endl
;
return
1
;
}
}
// test text file with utf-8 bom
{
{
kwsys
::
ofstream
out
(
"bom.txt"
);
out
.
write
(
reinterpret_cast
<
const
char
*>
(
expected_bom_data
[
0
]
+
1
),
*
expected_bom_data
[
0
]);
out
<<
"Hello World"
;
}
kwsys
::
ifstream
in
(
"bom.txt"
);
kwsys
::
FStream
::
BOM
bom
=
kwsys
::
FStream
::
ReadBOM
(
in
);
if
(
bom
!=
kwsys
::
FStream
::
BOM_UTF8
)
{
std
::
cout
<<
"Unexpected BOM for utf-8 case"
<<
std
::
endl
;
return
1
;
}
char
data
[
45
];
in
.
read
(
data
,
file_data
[
0
][
0
]);
if
(
!
in
.
good
())
{
std
::
cout
<<
"Unable to read data for utf-8 case"
<<
std
::
endl
;
return
1
;
}
if
(
memcmp
(
data
,
file_data
[
0
]
+
1
,
file_data
[
0
][
0
])
!=
0
)
{
std
::
cout
<<
"Incorrect read data for utf-8 case"
<<
std
::
endl
;
return
1
;
}
}
return
0
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment