FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Arduino/Solid.Arduino.Test/StringExtensionsTester.cs at master · SolidSoils/Arduino · GitHub
SolidSoils
Arduino
Repository navigation
Code
Issues
8
(8)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Arduino
/
Solid.Arduino.Test
/
StringExtensionsTester.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
119 lines (106 loc) · 3.52 KB
Breadcrumbs
Arduino
/
Solid.Arduino.Test
/
StringExtensionsTester.cs
Copy path
File metadata and controls
119 lines (106 loc) · 3.52 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using
System
;
using
Microsoft
.
VisualStudio
.
TestTools
.
UnitTesting
;
namespace
Solid
.
Arduino
.
Test
{
[
TestClass
]
public
class
StringExtensionsTester
{
[
TestMethod
]
public
void
ToBinaryCodedDecimal
(
)
{
byte
[
]
getal
=
"34"
.
ToBinaryCodedDecimal
(
)
;
Assert
.
AreEqual
(
1
,
getal
.
Length
)
;
Assert
.
AreEqual
(
0x34
,
getal
[
0
]
)
;
}
[
TestMethod
]
public
void
ToBinaryCodedDecimal_AllDigits
(
)
{
byte
[
]
getal
=
"0123456789"
.
ToBinaryCodedDecimal
(
)
;
Assert
.
AreEqual
(
5
,
getal
.
Length
)
;
Assert
.
AreEqual
(
0x01
,
getal
[
0
]
)
;
Assert
.
AreEqual
(
0x23
,
getal
[
1
]
)
;
Assert
.
AreEqual
(
0x45
,
getal
[
2
]
)
;
Assert
.
AreEqual
(
0x67
,
getal
[
3
]
)
;
Assert
.
AreEqual
(
0x89
,
getal
[
4
]
)
;
}
[
TestMethod
]
public
void
ToBinaryCodedDecimal_AllDigits_LittleEndian
(
)
{
byte
[
]
getal
=
"0123456789"
.
ToBinaryCodedDecimal
(
true
)
;
Assert
.
AreEqual
(
5
,
getal
.
Length
)
;
Assert
.
AreEqual
(
0x98
,
getal
[
0
]
)
;
Assert
.
AreEqual
(
0x76
,
getal
[
1
]
)
;
Assert
.
AreEqual
(
0x54
,
getal
[
2
]
)
;
Assert
.
AreEqual
(
0x32
,
getal
[
3
]
)
;
Assert
.
AreEqual
(
0x10
,
getal
[
4
]
)
;
}
[
TestMethod
]
public
void
ToBinaryCodedDecimal_OneDigit
(
)
{
byte
[
]
getal
=
"5"
.
ToBinaryCodedDecimal
(
)
;
Assert
.
AreEqual
(
1
,
getal
.
Length
)
;
Assert
.
AreEqual
(
0x05
,
getal
[
0
]
)
;
}
[
TestMethod
]
public
void
ToBinaryCodedDecimal_LittleEndian
(
)
{
byte
[
]
getal
=
"67"
.
ToBinaryCodedDecimal
(
true
)
;
Assert
.
AreEqual
(
1
,
getal
.
Length
)
;
Assert
.
AreEqual
(
0x76
,
getal
[
0
]
)
;
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
)
)
]
public
void
ToBinaryCodedDecimal_NullString
(
)
{
string
g
=
null
;
byte
[
]
getal
=
g
.
ToBinaryCodedDecimal
(
)
;
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
)
)
]
public
void
ToBinaryCodedDecimal_AlphaNumeric
(
)
{
string
g
=
"987A33"
;
byte
[
]
getal
=
g
.
ToBinaryCodedDecimal
(
)
;
}
[
TestMethod
]
public
void
ToBinaryCodedDecimal_EmptyString
(
)
{
byte
[
]
getal
=
string
.
Empty
.
ToBinaryCodedDecimal
(
)
;
Assert
.
AreEqual
(
0
,
getal
.
Length
)
;
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
)
)
]
public
void
To14BitIso_NullString
(
)
{
string
g
=
null
;
byte
[
]
getal
=
g
.
To14BitIso
(
)
;
Assert
.
AreEqual
(
0
,
getal
.
Length
)
;
}
[
TestMethod
]
public
void
To14BitIso_EmptyString
(
)
{
byte
[
]
getal
=
string
.
Empty
.
To14BitIso
(
)
;
Assert
.
AreEqual
(
0
,
getal
.
Length
)
;
}
[
TestMethod
]
public
void
To14BitIso_SingleCharacter
(
)
{
byte
[
]
getal
=
"A"
.
To14BitIso
(
)
;
Assert
.
AreEqual
(
2
,
getal
.
Length
)
;
Assert
.
AreEqual
(
65
,
getal
[
0
]
)
;
Assert
.
AreEqual
(
0
,
getal
[
1
]
)
;
}
[
TestMethod
]
public
void
To14BitIso_3Characters
(
)
{
byte
[
]
getal
=
"ABC"
.
To14BitIso
(
)
;
Assert
.
AreEqual
(
6
,
getal
.
Length
)
;
Assert
.
AreEqual
(
65
,
getal
[
0
]
)
;
Assert
.
AreEqual
(
0
,
getal
[
1
]
)
;
Assert
.
AreEqual
(
66
,
getal
[
2
]
)
;
Assert
.
AreEqual
(
0
,
getal
[
3
]
)
;
Assert
.
AreEqual
(
67
,
getal
[
4
]
)
;
Assert
.
AreEqual
(
0
,
getal
[
5
]
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL