我需要对存储在C ++向量中的数字列表进行排序:
@RunWith(MockitoJUnitRunner.class)
public class TagControllerTest {
private MockMvc mockMvc;
@Before
public void setup() {
JacksonTester.initFields(this, new ObjectMapper());
mockMvc = MockMvcBuilders.standaloneSetup(tagController).setControllerAdvice(new GlobalExceptionHandlerController()).build();
}
@Test
public void shouldntAllowToSetTagNameEmpty() throws Exception {
Tag tag1 = new Tag();
mockMvc.perform(post("/api/tags").contentType(MediaType.APPLICATION_JSON)
.content(jsonTags.write(tag1).getJson()))
.andExpect(status().isBadRequest());
}
按照上述代码,ax向量的顺序应为:
@RestControllerAdvice
public class GlobalExceptionHandlerController extends ResponseEntityExceptionHandler {
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(
MethodArgumentNotValidException ex,
HttpHeaders headers,
HttpStatus status,
WebRequest request) {
String bodyOfResponse = ex.getMessage();
return new ResponseEntity(bodyOfResponse, headers, HttpStatus.BAD_REQUEST);
}
我无法获得需要在compare函数中添加的内容吗?
答案 0 :(得分:1)
您的比较不是基于向量的内容,而是基于向量的大小
此外,在比较中,您通过值而不是通过const引用传递Oid,这无济于事,因为它们每次都被复制