在其中一个C源代码文件中,我找到了以下行(宏):
#define USE(x) (x) = (x)
Run Code Online (Sandbox Code Playgroud)
它是这样使用的:
int method(Obj *context)
{
USE(context);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
谷歌搜索后,我发现了以下描述:
//宏来摆脱一些编译器警告
你能告诉我更多关于这个宏的信息吗?
谢谢你的回答!
在@Transactional 方法中间调用Hibernate flush() 是否有可能将不完整的结果保存在数据库中?例如,这个函数是否有可能将“John”保存到数据库中?
@Transactional
public void tt() {
Student s = new Student("John");
em.persist(s);
em.flush();
// Perform some calculations that change some attributes of the instance
s.setName("Jeff");
}
Run Code Online (Sandbox Code Playgroud)
我用 H2 内存数据库尝试过它,它没有保存不完整的事务更改。但是在某些条件下是否可能并且可能使用另一个数据库引擎?
当我尝试测试此方法时
static void validatePostcode(final String postcode, final String addressLine)
{
if(! hasValidPostcode(postcode, addressLine)) {
throw new InvalidFieldException("Postcode is null or empty ");
}
}
Run Code Online (Sandbox Code Playgroud)
使用以下测试
@Test
public void testThrowsAnException()
{
assertThatThrownBy(validatePostcode("", "")).isInstanceOf(InvalidFieldException.class);
}
Run Code Online (Sandbox Code Playgroud)
我在 IntelliJ 中收到此错误消息
断言中的 assertThatThrownBy (org.assertj.core.api.ThrowableAssert.ThrowingCallable) 不能应用于 (void)
与assertThatExceptionOfType.
是否可以使用 AssertJ 测试该静态方法实际上引发了未经检查的异常?我应该在考试中改变什么?
问题是Logger没有使用Logger.getLogger(class_name.class.getName())方法初始化 .你可以看到下面的代码.我标记了导致异常的行.我必须注意,我也试过没有静态setLevel块.
// File that contains logger
public class Experience {
private final static Experience INSTANCE = new Experience();
private final static Logger LOGGER = Logger.getLogger(Experience.class.getName());
private MainFrame main_frame;
static {
LOGGER.setLevel(Level.SEVERE);
}
public static Experience getInstance()
{
return INSTANCE;
}
private Experience()
{
try
{
FileHandler fh = new FileHandler(System.getProperty("user.dir") + "/log.txt");
fh.setFormatter(new XPLogFormatter());
LOGGER.addHandler(fh); // NULLPOINTEREXCEPION HERE
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
// Just a loader
public class Loader
{ …Run Code Online (Sandbox Code Playgroud)