-
Notifications
You must be signed in to change notification settings - Fork 71
/
BitArgumentProvider.java
47 lines (38 loc) · 1.35 KB
/
BitArgumentProvider.java
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
/*
* Copyright 2016-2023 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* http://www.eclipse.org/legal/epl-v20.html
*/
package org.junitpioneer.jupiter.cartesian;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.extension.ExtensionContext;
// implementation example, does not contain tests
public class BitArgumentProvider {
// tag::cartesian_bit_source_annotation[]
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@CartesianArgumentsSource(BitArgumentsProvider.class)
public @interface BitSource {
}
// end::cartesian_bit_source_annotation[]
// tag::cartesian_bit_argument_provider[]
class BitArgumentsProvider implements CartesianMethodArgumentsProvider {
@Override
public ArgumentSets provideArguments(ExtensionContext context) {
int paramCount = context.getRequiredTestMethod().getParameters().length;
ArgumentSets sets = ArgumentSets.create();
for (int i = 0; i < paramCount; i++) {
sets.argumentsForNextParameter(0, 1);
}
return sets;
}
}
// end::cartesian_bit_argument_provider[]
}