Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
b76d6b5c
Commit
b76d6b5c
authored
Jun 14, 2018
by
Mark OLESEN
Browse files
STYLE: adjust tests for some updates in methods (issue
#876
)
parent
ba156655
Changes
3
Hide whitespace changes
Inline
Side-by-side
applications/test/PackedList/Test-PackedList.C
View file @
b76d6b5c
...
...
@@ -41,15 +41,15 @@ using namespace Foam;
template
<
unsigned
nBits
>
inline
void
reportInfo
()
{
const
unsigned
offset
=
PackedList
<
nBits
>::
packing
()
;
const
unsigned
offset
=
PackedList
<
nBits
>::
elem_per_block
;
unsigned
useSHL
=
((
1u
<<
(
nBits
*
offset
))
-
1
);
unsigned
useSHR
=
(
~
0u
>>
(
sizeof
(
unsigned
)
*
CHAR_BIT
-
nBits
*
offset
));
Info
<<
nl
<<
"PackedList<"
<<
nBits
<<
">"
<<
nl
<<
" max_value: "
<<
PackedList
<
nBits
>::
max_value
()
<<
nl
<<
" packing: "
<<
PackedList
<
nBits
>::
packing
()
<<
nl
<<
" max_value: "
<<
PackedList
<
nBits
>::
max_value
<<
nl
<<
" packing: "
<<
PackedList
<
nBits
>::
elem_per_block
<<
nl
<<
" utilization: "
<<
(
nBits
*
offset
)
<<
nl
;
Info
<<
" Masking:"
<<
nl
...
...
@@ -61,7 +61,7 @@ inline void reportInfo()
hex
(
Info
);
Info
<<
" maskLower: "
<<
PackedList
<
nBits
>::
mask
L
ower
(
PackedList
<
nBits
>::
packing
()
)
<<
PackedList
<
nBits
>::
mask
_l
ower
(
PackedList
<
nBits
>::
elem_per_block
)
<<
nl
<<
" useSHL: "
<<
useSHL
<<
nl
<<
" useSHR: "
<<
useSHR
<<
nl
;
...
...
applications/test/PackedList1/Test-PackedList1.C
View file @
b76d6b5c
...
...
@@ -111,16 +111,11 @@ int main(int argc, char *argv[])
list1
[
4
]
=
list1
[
2
];
report
(
list1
);
Info
<<
"
\n
test assign between references, with chaining
\n
"
;
list1
[
0
]
=
1
;
list1
[
4
]
=
1
;
report
(
list1
);
Info
<<
"
\n
test assign between references, with chaining and auto-vivify
\n
"
;
Info
<<
"
\n
set auto-vivify entries
\n
"
;
list1
[
1
]
=
2
;
list1
[
8
]
=
2
;
list1
[
10
]
=
2
;
list1
[
14
]
=
2
;
list1
.
set
(
8
,
2
)
;
list1
.
set
(
10
,
2
)
;
list1
.
set
(
14
,
2
)
;
report
(
list1
);
Info
<<
"
\n
test operator== between references
\n
"
;
...
...
@@ -160,39 +155,57 @@ int main(int argc, char *argv[])
report
(
constLst
);
Info
<<
"
\n
test operator[] non-const with out-of-range index
\n
"
;
if
(
list1
[
20
])
// Expect failure
const
bool
throwingError
=
FatalError
.
throwExceptions
();
try
{
Info
<<
"[20] is true (unexpected)
\n
"
;
if
(
list1
[
20
])
{
Info
<<
"[20] is true (unexpected)
\n
"
;
}
else
{
Info
<<
"[20] is false (expected) but list was resized?? "
<<
"(non-const)
\n
"
;
}
}
else
catch
(
Foam
::
error
&
err
)
{
Info
<<
"[20] is false (expected) but list was resized?? "
<<
"(non-const)
\n
"
;
Info
<<
"Failed (expected) "
<<
err
<<
nl
<<
endl
;
}
FatalError
.
throwExceptions
(
throwingError
);
report
(
list1
);
}
Info
<<
"
\n
test operator[] with out-of-range index
\n
"
;
if
(
!
list1
[
20
])
{
Info
<<
"[20] is false, as expected
\n
"
;
Info
<<
"
\n
test operator[] with out-of-range index
\n
"
;
// Expect failure
const
bool
throwingError
=
FatalError
.
throwExceptions
();
try
{
if
(
!
list1
[
20
])
{
Info
<<
"[20] is false, as expected for const-access
\n
"
;
}
}
catch
(
Foam
::
error
&
err
)
{
Info
<<
"Failed (expected) "
<<
err
<<
nl
<<
endl
;
}
FatalError
.
throwExceptions
(
throwingError
);
report
(
list1
);
}
report
(
list1
);
Info
<<
"
\n
test resize with value (without reallocation)
\n
"
;
list1
.
resize
(
8
,
list1
.
max_value
);
report
(
list1
);
//Info<< "\ntest flip() function\n";
//list1.flip();
//report(list1);
//Info<< "\nre-flip()\n";
//list1.flip();
//report(list1);
Info
<<
"
\n
test set() function
\n
"
;
list1
.
set
(
1
,
5
);
report
(
list1
);
...
...
@@ -239,19 +252,36 @@ int main(int argc, char *argv[])
list1
.
setCapacity
(
100
);
report
(
list1
);
Info
<<
"
\n
test operator[] assignment
\n
"
;
list1
[
16
]
=
5
;
report
(
list1
);
// Expect failure
{
const
bool
throwingError
=
FatalError
.
throwExceptions
();
Info
<<
"
\n
test operator[] assignment with auto-vivify
\n
"
;
try
{
list1
[
16
]
=
5
;
list1
[
36
]
=
list1
.
max_value
;
}
catch
(
Foam
::
error
&
err
)
{
Info
<<
"Failed (expected) "
<<
err
<<
nl
<<
endl
;
Info
<<
"Using set(...) instead"
<<
nl
;
list1
.
set
(
36
,
list1
.
max_value
);
}
FatalError
.
throwExceptions
(
throwingError
);
report
(
list1
);
}
Info
<<
"
\n
test operator[] assignment with auto-vivify
\n
"
;
list1
[
36
]
=
list1
.
max_value
;
report
(
list1
);
Info
<<
"
\n
test setCapacity smaller
\n
"
;
list1
.
setCapacity
(
24
);
report
(
list1
);
Info
<<
"
\n
test resize much
small
er
\n
"
;
Info
<<
"
\n
test resize much
larg
er
\n
"
;
list1
.
resize
(
150
);
report
(
list1
);
...
...
@@ -260,26 +290,24 @@ int main(int argc, char *argv[])
report
(
list1
);
// Add in some misc values
list1
[
31
]
=
1
;
list1
[
32
]
=
2
;
list1
[
33
]
=
3
;
list1
.
set
(
31
,
1
)
;
list1
.
set
(
32
,
2
)
;
list1
.
set
(
33
,
3
)
;
Info
<<
"
\n
test get() method
\n
"
;
Info
<<
"get(10):"
<<
list1
.
get
(
10
)
<<
" and list[10]:"
<<
list1
[
10
]
<<
"
\n
"
;
report
(
list1
);
Info
<<
"
\n
test
operator[]
auto-vivify
\n
"
;
Info
<<
"
\n
test
set()
auto-vivify
\n
"
;
Info
<<
"size:"
<<
list1
.
size
()
<<
"
\n
"
;
const
unsigned
int
val
=
list1
[
45
];
Info
<<
"list[45]:"
<<
val
<<
"
\n
"
;
Info
<<
"list[45]:"
<<
list1
.
get
(
45
)
<<
"
\n
"
;
Info
<<
"size after read:"
<<
list1
.
size
()
<<
"
\n
"
;
list1
[
45
]
=
list1
.
max_value
;
list1
.
set
(
45
,
list1
.
max_value
)
;
Info
<<
"size after write:"
<<
list1
.
size
()
<<
"
\n
"
;
Info
<<
"list[45]:"
<<
list1
[
45
]
<<
"
\n
"
;
list1
[
49
]
=
list1
[
100
]
;
list1
.
set
(
49
,
list1
.
get
(
100
))
;
report
(
list1
);
...
...
applications/test/PatchTools/Test-PatchTools.C
View file @
b76d6b5c
...
...
@@ -35,6 +35,7 @@ Description
#include
"volFields.H"
#include
"Time.H"
#include
"OBJstream.H"
#include
"fvCFD.H"
using
namespace
Foam
;
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment