我正在rspec
为我的应用程序编写测试.为了授权我发送token
标题:
request.headers['token'] = '000000099'
get :index
Run Code Online (Sandbox Code Playgroud)
在控制器端,我可以读取该值request.env["HTTP_TOKEN"]
但是env["HTTP_TOKEN"]
为空.
它们之间有什么区别,我该怎么设置env
而不是request.env
?
我正在使用以下代码来替换Roslyn的方法体;
/* method is instance of MethodDeclarationSyntax */
BlockSyntax newBody = SyntaxFactory.Block(SyntaxFactory.ParseStatement("throw new NotImplementedException();"));
BlockSyntax body = method.Body;
var modifiedMethod = method.ReplaceNode(body, newBody);
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,删除方法后换行,如果方法后面有一个#region
或#endregion
标记,则会发生错误.
例如
#region
static void RemoveRegions(string str)
{
return;
}
#endregion
Run Code Online (Sandbox Code Playgroud)
并在更换身体后
#region
static void RemoveRegions(string str)
{
throw new NotImplementedException();
} #endregion // This cause to compiling error
Run Code Online (Sandbox Code Playgroud) 我的代码:
long long difft, intrv ;
cout << "difft = " << difft << endl;
cout << "intrv = " << intrv << endl;
cout << "difft mod intrv = " << difft%intrv << endl;
Run Code Online (Sandbox Code Playgroud)
输出:
difft = 0
intrv = 0
difft mod intrv = 1
Run Code Online (Sandbox Code Playgroud)
0%0的结果为零,但在我的代码中结果为"1",为什么?