我如何能够在此代码中更改AdapterName值?

时间:2017-05-18 10:02:08

标签: c++

public class Stack
{
    WebDriver driver = null;
    ExtentReports logger = ExtentReports.get(CustomReports.class); //Initinating the logger
    logger.init("C:\\Users\\siddhesh.kalgaonkar\\Documents\\Reports\\SecondReport.html", true);
    System.setProperty("webdriver.firefox.marionette", "C:\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.manage().window().maximize();

@Test(priority = 1)
public void verifyTitle() 
{

    logger.startTest("Verify Title Test");//Starting the test logger
    logger.log(LogStatus.INFO, "Browser is up and running..");
    driver.get("http://google.com");
    logger.log(LogStatus.INFO, "Application is up and running..");
    String title = driver.getTitle();
    Assert.assertTrue(title.contains("Google")); //This will pass
    logger.log(LogStatus.INFO, "Title is verified..");
    logger.endTest();//Ending the test logger

}

@Test(priority = 2)
public void verifyTitle2() 
{

    logger.startTest("Verify Failing the test case");//Starting the test logger
    String title1 = driver.getTitle();
    Assert.assertTrue(title1.contains("Selenium")); //This will fail
    logger.log(LogStatus.INFO, "Title is verified..");
    logger.endTest();//Ending the test logger
}

@AfterSuite
public void afterFailed() 
{ 
    driver.get("C:\\Users\\siddhesh.kalgaonkar\\Documents\\Reports\\SecondReport.html");
}
}

我想知道是否可以更改DWORD GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen) { pAdapterInfo->AdapterName return GetAdaptersInfo(pAdapterInfo, pOutBufLen) } 中的AdapterName值并返回新的pAdapterInfo

1 个答案:

答案 0 :(得分:0)

我应该提一下,我不知道你正在处理的Adaptor是什么。但是,尽管我对细节一无所知,但我可以告诉你,这不起作用(明显的错误已修复,假设AdapterName是一个字符串):

DWORD GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
{
    pAdapterInfo->AdapterName = "foo";
    return GetAdaptersInfo(pAdapterInfo, pOutBufLen);
}

您正在以递归方式调用该函数,并且该递归没有结束。相反,你可以这样做:

DWORD GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen,STRING_t newName)
{
    pAdapterInfo->AdapterName = newName;
    return GetAdaptersInfo(pAdapterInfo, pOutBufLen);
}

我假设DWORD GetAdaptersInfo(PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)存在且可以被调用。

但请注意,PID_ADAPTER_INFO作为值类型或引用类型,GetAdapterInfo的调用者没有机会注意到他获得的AdapterInfo来自不同的名称,因为(如果它是一个值),他的pAdapterInfo仍将保留旧名称。