Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMPStaticAnalyzer
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
Container Registry
Model registry
Operate
Environments
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
Open Source Software
SMPStaticAnalyzer
Commits
ba15264b
Commit
ba15264b
authored
6 years ago
by
Clark Coleman
Browse files
Options
Downloads
Patches
Plain Diff
Commit synthetic test source code.
parent
95a4e05c
No related branches found
No related tags found
No related merge requests found
Pipeline
#2905
passed
6 years ago
Stage: clean
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/starstest.c
+110
-0
110 additions, 0 deletions
tests/starstest.c
with
110 additions
and
0 deletions
tests/starstest.c
0 → 100644
+
110
−
0
View file @
ba15264b
#include
<stdlib.h>
#include
<stdio.h>
static
int
buffer
[
20
];
unsigned
int
GetIndex
(
void
)
{
unsigned
int
randindex
=
rand
()
%
20
;
return
randindex
;
}
void
RandomElementSwap
(
const
unsigned
int
index2
)
{
unsigned
int
index1
=
rand
()
%
20
;
int
temp
=
buffer
[
index1
];
buffer
[
index1
]
=
buffer
[
index2
];
buffer
[
index2
]
=
temp
;
return
;
}
unsigned
int
GetValueBasedIndex
(
void
)
{
unsigned
int
value
=
0
;
unsigned
int
randindex
=
rand
()
%
20
;
switch
(
randindex
)
{
case
0
:
value
=
buffer
[
17
];
break
;
case
1
:
value
=
buffer
[
12
];
break
;
case
2
:
value
=
buffer
[
4
];
break
;
case
3
:
value
=
buffer
[
1
];
break
;
case
4
:
value
=
buffer
[
18
];
break
;
case
5
:
value
=
buffer
[
7
];
break
;
case
6
:
value
=
buffer
[
3
];
break
;
case
7
:
value
=
buffer
[
19
];
break
;
case
8
:
value
=
buffer
[
2
];
break
;
case
9
:
value
=
buffer
[
16
];
break
;
case
10
:
value
=
buffer
[
9
];
break
;
case
11
:
value
=
buffer
[
5
];
break
;
case
12
:
value
=
buffer
[
15
];
break
;
case
13
:
value
=
buffer
[
6
];
break
;
case
14
:
value
=
buffer
[
14
];
break
;
case
15
:
value
=
buffer
[
8
];
break
;
case
16
:
value
=
buffer
[
10
];
break
;
case
17
:
value
=
buffer
[
0
];
break
;
case
18
:
value
=
buffer
[
11
];
break
;
case
19
:
value
=
buffer
[
13
];
break
;
default:
value
=
buffer
[
0
];
break
;
}
return
(
value
%
20
);
}
int
main
()
{
unsigned
int
index
,
randindex
;
srand
(
17
);
/* seed the generator */
for
(
index
=
0
;
index
<
20
;
++
index
)
{
buffer
[
index
]
=
rand
();
}
randindex
=
GetValueBasedIndex
();
RandomElementSwap
(
randindex
);
printf
(
"Here are 20 random integers:
\n
"
);
for
(
index
=
0
;
index
<
20
;
++
index
)
{
randindex
=
rand
()
%
20
;
printf
(
"%d
\n
"
,
buffer
[
randindex
]);
}
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