Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
ButtonPusher
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Button Pusher
ButtonPusher
Commits
f7a0414a
Commit
f7a0414a
authored
Feb 07, 2018
by
16이상민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Write a test for the class "MotionStatusExtractor"
parent
a7e8ca71
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
276 additions
and
17 deletions
+276
-17
MotionStatusExtractorTest.cs
Assets/Editor/MotionStatusExtractorTest.cs
+245
-0
MotionStatusExtractorTest.cs.meta
Assets/Editor/MotionStatusExtractorTest.cs.meta
+13
-0
MotionState.cs
Assets/MotionAnalysis/MotionState.cs
+2
-1
MotionStatusExtractor.cs
Assets/StatusConvert/MotionStatusExtractor.cs
+16
-16
No files found.
Assets/Editor/MotionStatusExtractorTest.cs
0 → 100644
View file @
f7a0414a
using
NUnit.Framework
;
using
MotionAnalysis
;
using
StatusConvert
;
using
System.Linq
;
using
System.Collections.Generic
;
class
MotionStatusExtractorTest
{
[
Test
]
public
void
Output_Should_None_State_When_InvalidName
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckNotContain
(
"asdf"
,
MotionState
.
ALL
,
MotionStatus
.
None
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be none state when entered invalid name."
);
}
[
Test
]
public
void
Output_Should_Prepared_State_When_Name_Clap_And_Valid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckContain
(
"Clap"
,
MotionState
.
CLAP_PREPARE
,
MotionStatus
.
Prepared
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be prepared state when name is Clap and valid input."
);
}
[
Test
]
public
void
Output_Should_Done_State_When_Name_Clap_And_Valid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
Check
(
"Clap"
,
MotionState
.
CLAP_DONE
,
MotionState
.
CLAP_PREPARE
,
MotionStatus
.
Done
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be done state when name is Clap and valid input."
);
}
[
Test
]
public
void
Output_Should_None_State_When_Name_Clap_And_Invalid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckNotContain
(
"Clap"
,
MotionState
.
CLAP_PREPARE
|
MotionState
.
CLAP_DONE
,
MotionStatus
.
None
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be none state when name is Clap and invalid input."
);
}
[
Test
]
public
void
Output_Should_Prepared_State_When_Name_PushUpLeft_And_Valid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckContain
(
"PushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_UP_LEFT
,
MotionStatus
.
Prepared
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be prepared state when name is PushUpLeft and valid input."
);
}
[
Test
]
public
void
Output_Should_Done_State_When_Name_PushUpLeft_And_Valid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
Check
(
"PushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_DOWN_LEFT
,
MotionState
.
HAND_MOVE_UP_LEFT
,
MotionStatus
.
Done
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be done state when name is PushUpLeft and valid input."
);
}
[
Test
]
public
void
Output_Should_None_State_When_Name_PushUpLeft_And_Invalid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckNotContain
(
"PushUpLeft"
,
MotionState
.
HURRAY
,
MotionStatus
.
None
)
||
StateChecker
.
CheckNotContain
(
"PushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_UP_LEFT
,
MotionStatus
.
None
)
||
StateChecker
.
CheckNotContain
(
"PushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_DOWN_LEFT
,
MotionStatus
.
None
)
||
StateChecker
.
CheckNotContain
(
"PushUpLeft"
,
MotionState
.
HAND_MOVE_UP_LEFT
|
MotionState
.
HAND_MOVE_DOWN_LEFT
,
MotionStatus
.
None
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be none state when name is PushUpLeft and invalid input."
);
}
[
Test
]
public
void
Output_Should_Prepared_State_When_Name_JumpPushUpLeft_And_Valid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckContain
(
"JumpPushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
JUMP_PREPARE
|
MotionState
.
HAND_MOVE_UP_LEFT
,
MotionStatus
.
Prepared
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be prepared state when name is JumpPushUpLeft and valid input."
);
}
[
Test
]
public
void
Output_Should_Done_State_When_Name_JumpPushUpLeft_And_Valid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
Check
(
"JumpPushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
JUMP_DONE
|
MotionState
.
HAND_MOVE_DOWN_LEFT
,
MotionState
.
JUMP_PREPARE
|
MotionState
.
HAND_MOVE_UP_LEFT
,
MotionStatus
.
Done
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be done state when name is JumpPushUpLeft and valid input."
);
}
[
Test
]
public
void
Output_Should_None_State_When_Name_JumpPushUpLeft_And_Invalid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckNotContain
(
"JumpPushUpLeft"
,
MotionState
.
HURRAY
,
MotionStatus
.
None
)
||
StateChecker
.
CheckNotContain
(
"JumpPushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
JUMP_PREPARE
|
MotionState
.
HAND_MOVE_UP_LEFT
,
MotionStatus
.
None
)
||
StateChecker
.
CheckNotContain
(
"JumpPushUpLeft"
,
MotionState
.
HURRAY
|
MotionState
.
JUMP_DONE
|
MotionState
.
HAND_MOVE_DOWN_LEFT
,
MotionStatus
.
None
)
||
StateChecker
.
CheckNotContain
(
"JumpPushUpLeft"
,
MotionState
.
JUMP_PREPARE
|
MotionState
.
JUMP_DONE
|
MotionState
.
HAND_MOVE_UP_LEFT
|
MotionState
.
HAND_MOVE_DOWN_LEFT
,
MotionStatus
.
None
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be none state when name is JumpPushUpLeft and invalid input."
);
}
[
Test
]
public
void
Output_Should_Prepared_Done_State_When_Name_Jesus_And_Valid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckContain
(
"Jesus"
,
MotionState
.
JESUS
,
MotionStatus
.
Prepared
|
MotionStatus
.
Done
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be done state when name is Jesus and valid input."
);
}
[
Test
]
public
void
Output_Should_None_State_When_Name_Jesus_And_Invalid_Input
()
{
var
expected
=
true
;
var
actual
=
StateChecker
.
CheckNotContain
(
"Jesus"
,
MotionState
.
JESUS
,
MotionStatus
.
None
);
Assert
.
AreEqual
(
expected
,
actual
,
"output should be none state when name is Jesus and invalid input."
);
}
}
public
static
class
StateChecker
{
public
static
bool
Check
(
string
name
,
MotionState
contain
,
MotionState
none
,
MotionStatus
result
)
{
return
AreCorrectResults
(
name
,
result
,
ConditionalPossibiltiy
(
contain
,
none
));
}
public
static
bool
CheckContain
(
string
name
,
MotionState
contain
,
MotionStatus
result
)
{
return
AreCorrectResults
(
name
,
result
,
AllPossibilityContainAllState
(
contain
));
}
public
static
bool
CheckNotContain
(
string
name
,
MotionState
none
,
MotionStatus
result
)
{
return
AreCorrectResults
(
name
,
result
,
AllPossibilityNotContainAllState
(
none
));
}
private
static
IEnumerable
<
MotionState
>
AllPossibility
()
{
return
Enumerable
.
Range
(
0
,
(
int
)
MotionState
.
ALL
+
1
)
.
Select
(
x
=>
(
MotionState
)
x
);
}
private
static
IEnumerable
<
MotionState
>
AllPossibilityContainAllState
(
MotionState
contain
)
{
return
AllPossibility
().
Where
(
x
=>
(
x
&
contain
)
==
contain
);
}
private
static
IEnumerable
<
MotionState
>
AllPossibilityNotContainAllState
(
MotionState
none
)
{
return
AllPossibility
().
Where
(
x
=>
(
x
&
none
)
==
MotionState
.
UNKNOWN
);
}
private
static
IEnumerable
<
MotionState
>
ConditionalPossibiltiy
(
MotionState
contain
,
MotionState
none
)
{
return
AllPossibility
().
Where
(
x
=>
(
x
&
contain
)
==
contain
&&
(
x
&
none
)
==
MotionState
.
UNKNOWN
);
}
private
static
bool
AreCorrectResults
(
string
name
,
MotionStatus
result
,
IEnumerable
<
MotionState
>
possibilities
)
{
return
NumberCorrectResults
(
name
,
result
,
possibilities
)
==
possibilities
.
Count
();
}
private
static
int
NumberCorrectResults
(
string
name
,
MotionStatus
result
,
IEnumerable
<
MotionState
>
possibilities
)
{
return
possibilities
.
Select
(
x
=>
MotionStatusExtractor
.
Extract
(
name
,
x
))
.
Where
(
x
=>
x
==
result
)
.
Count
();
}
}
Assets/Editor/MotionStatusExtractorTest.cs.meta
0 → 100644
View file @
f7a0414a
fileFormatVersion: 2
guid: 49ca8807c8e90e644b82eac88447687e
timeCreated: 1517880293
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/MotionAnalysis/MotionState.cs
View file @
f7a0414a
...
@@ -24,6 +24,7 @@ namespace MotionAnalysis
...
@@ -24,6 +24,7 @@ namespace MotionAnalysis
JESUS
=
0x10000
,
JESUS
=
0x10000
,
HEADPHONE_LEFT
=
0x20000
,
HEADPHONE_LEFT
=
0x20000
,
HEADPHONE_RIGHT
=
0x40000
,
HEADPHONE_RIGHT
=
0x40000
,
ON_THE_TABLE
=
0x80000
ON_THE_TABLE
=
0x80000
,
ALL
=
0xFFFFF
}
}
}
}
\ No newline at end of file
Assets/StatusConvert/MotionStatusExtractor.cs
View file @
f7a0414a
...
@@ -25,58 +25,58 @@ namespace StatusConvert
...
@@ -25,58 +25,58 @@ namespace StatusConvert
{
{
"PushUpLeft"
,
new
Dictionary
<
string
,
MotionState
>
"PushUpLeft"
,
new
Dictionary
<
string
,
MotionState
>
{
{
{
"prepare"
,
MotionState
.
HURRAY
&
{
"prepare"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_UP_LEFT
},
MotionState
.
HAND_MOVE_UP_LEFT
},
{
"done"
,
MotionState
.
HURRAY
&
{
"done"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_DOWN_LEFT
}
MotionState
.
HAND_MOVE_DOWN_LEFT
}
}
}
},
},
{
{
"PushUpRight"
,
new
Dictionary
<
string
,
MotionState
>
"PushUpRight"
,
new
Dictionary
<
string
,
MotionState
>
{
{
{
"prepare"
,
MotionState
.
HURRAY
&
{
"prepare"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_UP_RIGHT
},
MotionState
.
HAND_MOVE_UP_RIGHT
},
{
"done"
,
MotionState
.
HURRAY
&
{
"done"
,
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_DOWN_RIGHT
}
MotionState
.
HAND_MOVE_DOWN_RIGHT
}
}
}
},
},
{
{
"JumpPushUpLeft"
,
new
Dictionary
<
string
,
MotionState
>
"JumpPushUpLeft"
,
new
Dictionary
<
string
,
MotionState
>
{
{
{
"prepare"
,
MotionState
.
JUMP_PREPARE
&
{
"prepare"
,
MotionState
.
JUMP_PREPARE
|
MotionState
.
HURRAY
&
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_UP_LEFT
},
MotionState
.
HAND_MOVE_UP_LEFT
},
{
"done"
,
MotionState
.
JUMP_DONE
&
{
"done"
,
MotionState
.
JUMP_DONE
|
MotionState
.
HURRAY
&
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_DOWN_LEFT
}
MotionState
.
HAND_MOVE_DOWN_LEFT
}
}
}
},
},
{
{
"JumpPushUpRight"
,
new
Dictionary
<
string
,
MotionState
>
"JumpPushUpRight"
,
new
Dictionary
<
string
,
MotionState
>
{
{
{
"prepare"
,
MotionState
.
JUMP_PREPARE
&
{
"prepare"
,
MotionState
.
JUMP_PREPARE
|
MotionState
.
HURRAY
&
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_UP_RIGHT
},
MotionState
.
HAND_MOVE_UP_RIGHT
},
{
"done"
,
MotionState
.
JUMP_DONE
&
{
"done"
,
MotionState
.
JUMP_DONE
|
MotionState
.
HURRAY
&
MotionState
.
HURRAY
|
MotionState
.
HAND_MOVE_DOWN_RIGHT
}
MotionState
.
HAND_MOVE_DOWN_RIGHT
}
}
}
},
},
{
{
"GuardLeft"
,
new
Dictionary
<
string
,
MotionState
>
"GuardLeft"
,
new
Dictionary
<
string
,
MotionState
>
{
{
{
"prepare"
,
MotionState
.
GUARD_BASE_LEFT
&
{
"prepare"
,
MotionState
.
GUARD_BASE_LEFT
|
MotionState
.
HAND_MOVE_UP_LEFT
},
MotionState
.
HAND_MOVE_UP_LEFT
},
{
"done"
,
MotionState
.
GUARD_BASE_LEFT
&
{
"done"
,
MotionState
.
GUARD_BASE_LEFT
|
MotionState
.
HAND_MOVE_DOWN_LEFT
}
MotionState
.
HAND_MOVE_DOWN_LEFT
}
}
}
},
},
{
{
"GuardRight"
,
new
Dictionary
<
string
,
MotionState
>
"GuardRight"
,
new
Dictionary
<
string
,
MotionState
>
{
{
{
"prepare"
,
MotionState
.
GUARD_BASE_RIGHT
&
{
"prepare"
,
MotionState
.
GUARD_BASE_RIGHT
|
MotionState
.
HAND_MOVE_UP_RIGHT
},
MotionState
.
HAND_MOVE_UP_RIGHT
},
{
"done"
,
MotionState
.
GUARD_BASE_RIGHT
&
{
"done"
,
MotionState
.
GUARD_BASE_RIGHT
|
MotionState
.
HAND_MOVE_DOWN_RIGHT
}
MotionState
.
HAND_MOVE_DOWN_RIGHT
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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